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

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
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
 
Upvote 0
Solution

Forum statistics

Threads
1,214,653
Messages
6,120,751
Members
448,989
Latest member
mariah3

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
Back
Top