Pulling Data from a sheet into a userform

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
2,573
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi Everyone

I have a userform called Userform1
and i want to pull data into it from
Sheets("Form Info").Range("A1")

I tried this but it didn't work any ideas how i do this and what i did wrong?

Thanks

Tony

Code:
[FONT=Calibri][SIZE=3][COLOR=#000000]Sub AAA_Calender1_tests()[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]      UserForm1.Show[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]     UserForm1.TextBox1.Value = Sheets("Form Info").Range("A1").Value[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]End Sub[/COLOR][/SIZE][/FONT]
 

Some videos you may like

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

KevCarter

Board Regular
Joined
Dec 7, 2013
Messages
98
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Tony,

Please try:

Code:
[COLOR=#000000][FONT=Calibri]UserForm1.TextBox1.Value = [/FONT][/COLOR]ThisWorkbook.Worksheets("[COLOR=#000000][FONT=Calibri]Form Info[/FONT][/COLOR]")[COLOR=#000000][FONT=Calibri].Range("A1").Value[/FONT][/COLOR]
 

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
2,573
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Thank you Kev,
Turns out I just had the order the wrong way Should do Show after but thanks for your help
Tony
 

KevCarter

Board Regular
Joined
Dec 7, 2013
Messages
98
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Tony,

I like to set my values in the initialize event of the user form. Just another option...

Code:
Sub AAA_Calender1_tests()
      UserForm1.Show
End Sub

Code:
Private Sub UserForm_initialize()
     Me.TextBox1.Value = ThisWorkbook.Worksheets("Form Info").Range("A1").Value
End sub
 

Watch MrExcel Video

Forum statistics

Threads
1,109,020
Messages
5,526,297
Members
409,694
Latest member
bastos21

This Week's Hot Topics

Top