halfsparrow
New Member
- Joined
- Feb 23, 2021
- Messages
- 6
- Office Version
- 365
- Platform
- Windows
Hello Everyone, I am stuck at a point in vba and really need help
I have a button in excel sheets upon clicking that button it opens a Userform named as UserForm1 ad it asks user to browse the excel excel and open it
Private Sub CommandButton1_Click()
Dim pathString As String
Dim resultWorkbook As Workbook
Dim found As Boolean
pathString = Application.GetOpenFilename(fileFilter:="All Files (* . xl*) , *.xl* ")
' check if it's already opened
For Each wb In Workbooks
If InStr(pathString, wb.Name) > 0 Then
Set resultWorkbook = wb
found = True
Exit For
End If
Next wb
If Not found Then
Set resultWorkbook = Workbooks.Open(pathString)
End If
Worksheets(3).Activate
Unload UserForm1
UserForm2.Show
End Sub
this is its code
and it opens UserForm2
Now i want textboxs in userform2 to be preloaded from a cell in excel file that a user opened
there are 4 textboxs named
HeatSup, HeatRet, CoolSup, CoolRet
and the cells in excel file are S6,S7,S8,S9
Thanks in Advance
I have a button in excel sheets upon clicking that button it opens a Userform named as UserForm1 ad it asks user to browse the excel excel and open it
Private Sub CommandButton1_Click()
Dim pathString As String
Dim resultWorkbook As Workbook
Dim found As Boolean
pathString = Application.GetOpenFilename(fileFilter:="All Files (* . xl*) , *.xl* ")
' check if it's already opened
For Each wb In Workbooks
If InStr(pathString, wb.Name) > 0 Then
Set resultWorkbook = wb
found = True
Exit For
End If
Next wb
If Not found Then
Set resultWorkbook = Workbooks.Open(pathString)
End If
Worksheets(3).Activate
Unload UserForm1
UserForm2.Show
End Sub
this is its code
and it opens UserForm2
Now i want textboxs in userform2 to be preloaded from a cell in excel file that a user opened
there are 4 textboxs named
HeatSup, HeatRet, CoolSup, CoolRet
and the cells in excel file are S6,S7,S8,S9
Thanks in Advance