Textbox in userform not initialized when workbook opens

przemek

New Member
Joined
Jan 6, 2015
Messages
13
Hi


I want to display userform when workbook is opened by user. Userform have 4 Textbox that have to be updated from cells value in Thisworkbook. I started with


Code:
Private Sub Workbook_Open()
WelcomeToISC.Show
End Sub




and followed by Initialize code


Code:
Private Sub Userform_Initialize()
  
Dim t6, t7, t8, t9 As String
Dim ws As Worksheet
 
Set ws = ThisWorkbook.Sheets("Refresh info")
t6 = “Next update is planned for: “ & ws.Cells(4, 2)
Me.TextBox6.Text = t6
…..
End Sub






result is "Run-time error '424' : Object required." So i have changed Initialize from Userform_Initialize() to WelcomeToISC_Initialize() as per below. Files opens, userform is displayed but nothing is populated into Textbox. FYI there are other userforms in this file, that are triggered from module code.


Code:
Private Sub WelcomeToISC_Initialize()
  
Dim t6, t7, t8, t9 As String
Dim ws As Worksheet
 
Set ws = ThisWorkbook.Sheets("Refresh info")
t6 = “Next update is planned for: “ & ws.Cells(4, 2)
Me.TextBox6.Text = t6
…..
End Sub


Thanks for looking at this and you advice.
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
It should always be Userform_Initialize regardless of the name of the form. The error means you have a mistake in the Initialize code such as using an incorrect control name.
 
Upvote 0

Forum statistics

Threads
1,224,822
Messages
6,181,164
Members
453,021
Latest member
Justyna P

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