Sheet to form values

DarkOwl

New Member
Joined
Dec 28, 2004
Messages
34
Basically, i want to show a "record" in a table, upon the user selecting a code on the form. Heres the sub im having problems with.

Private Sub CommandButton1_Click()


Dim Searchkey As String


Searchkey = Code.Text

Sheets("Shipping and Payment").Select
Range("D5").Select

Do While ActiveCell <> ""
If ActiveCell.Text = Searchkey Then

ActiveCell.Offset(0, 1).Value = Telephone.Text
'Where "telephone" is the name of the textbox
ActiveCell.Offset(0, 1) = Invoicedate.Text
ActiveCell.Offset(0, 1) = CurrentPaymentstatus.Text
ActiveCell.Offset(0, 1) = Currentshippingstatus.Text
GoTo Lastline
End If
ActiveCell.Offset(1, 0).Activate
Loop
Lastline:





End Sub




Can anyone help as to how i can get cell values to show in textboxes on an userform?
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
DarkOwl,
To take a cell value and add it to a form control, just do this.

Userfrom1.textbox1 = Activecell.value

textbox1 will need to be equal to your controls correct name.

HTH
Cal
 
Upvote 0
Thankyou, i tired

ActiveCell.Offset(0, 1).Activate
Orderstatus.Telephone = ActiveCell.Value

but when i try, it still wont work :(

Can anyone else help?
 
Upvote 0
DarkOwl,
The code I gave you was to load a value from the worksheet to a userform with the worksheet is active. If you want to populate the userform field while the form is active(GotFocus), you need to do it like this.(A full worksheet reference)

TextBox1.Value = Sheets("Sheet1").Range("A1").Value

HTH
Cal
 
Upvote 0

Forum statistics

Threads
1,203,600
Messages
6,056,205
Members
444,850
Latest member
dancasta7

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