I have maintained two excel workbooks in different folders, in the first excel i have created an Userform which has two comboboxes in it, i have declared an global variable "EpcName" in Userform and this global variable stores the second combobox selected value. Now my question is how can i use the value of Global variable from Userform to other workbook which is there in different folder.
Workbook 1 path(Where i have created userform) C:\Users\inkapb\AppData\Local\Temp\EPC AutoTool\Start Screen -UI\UI.xlsm
Workbook 2 path C:\Users\inkapb\AppData\Local\Temp\EPC AutoTool\Projects\Power Plant\Power Plant EPC 1.xlsm
Here is the code which i have written in the Userform
Public EpcName As String
Private Sub CommandButton1_Click()
Dim wb As Workbook
Dim ws As Worksheet
Set wb = Workbooks("UI.xlsm")
Set ws = wb.Worksheets("Sheet2")
Dim qwerty As String
Dim cf As Range
EpcName = Me.ComboBox2.Text 'Want to pass this String to other workbook
With ws
.Activate
With .Range("C1:C10000")
Set cf = .Find(what:=EpcName, _
lookat:=xlPart, searchorder:=xlByRows, searchdirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If cf = "" Then
MsgBox "nothing"
Else
Range(cf.Address).Select
Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
End If
End With
End With
End Sub
Any help is appreciated.