UserForm Load

halfsparrow

New Member
Joined
Feb 23, 2021
Messages
6
Office Version
  1. 365
Platform
  1. 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
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

diddi

Well-known Member
Joined
May 20, 2004
Messages
3,337
Office Version
  1. 2010
Platform
  1. Windows
try this
VBA Code:
Unload UserForm1
With UserForm2
    .HeatSup = Sheets("MySheet").Range("S6")
    .HeatRet = Sheets("MySheet").Range("S7")
    .CoolSup = Sheets("MySheet").Range("S8")
    .CoolRet = Sheets("MySheet").Range("S9")
    .Show
End with
 
Solution
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,479
Messages
5,831,915
Members
430,091
Latest member
Generally_confused

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top