User forms

Dundee Lad

Active Member
Joined
Sep 6, 2003
Messages
311
I am new to using the userform and was looking for some help. I have data in some cells which i want the userform to pick up. I also have some cells which I want populated by the userform input. I have managed to create the userforms but this is as far as |i have got. searched on the board but did not find anything as basic as this. can you help me?
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Hi

Have you looked into Built-in forms for Excel data?

These are standard forms that can apply to data ranges. Go to Data -> Forms. Perhaps worth having a quick read on Excel help - it may well serve what you are after.

Regards
Jon
 
Upvote 0
In the userform's Activate event (or Initialize event) you can use code like:
Code:
Me.Textbox1.Text = sheets("Sheet1").Range("A2").Value

and to reverse the process, just swap it round:
Code:
sheets("Sheet1").Range("A2").Value = Me.Textbox1.Text

You can also set the controlsource property of the controls on the userform to a range address, but I prefer to do it all through code.
HTH
 
Upvote 0
Rorya, I have tried your code

Private Sub UserForm_Activate()
Sheets("Sheet2").Range("c7").Value = Me.TextBox62.Text
Sheets("Sheet2").Range("d7").Value = Me.TextBox61.Text
End Sub

but when I check sheet 2 my data is missing and there is no data in the userform?
 
Upvote 0
Normally you would use the activate event to load data into your userform rather than the other way around because it is triggered when you show the userform. Your code is assigning the textbox values to the sheet ranges but the textboxes are probably blank at that point so you effectively clear the sheet ranges.
 
Upvote 0
Rorya, when I use the userform deactivate, it does not update the cells in excel? what am I doing wrong?

Code:
Private Sub UserForm_Deactivate()
Sheets("sheet3").Range("c4").Value = Me.TextBox62.Text
Sheets("sheet3").Range("d4").Value = Me.TextBox61.Text
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,657
Messages
6,120,769
Members
448,991
Latest member
Hanakoro

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