populate text boxes from data in worksheet

  • Thread starter Thread starter Lyndon107
  • Start date Start date
L

Lyndon107

107I am a rookie excel programmer trying to display data from a worksheet to
textboxes which I thought to be a very simple operation but Excel just
ignores the instuctions i.e Dim Rw As Integer
Rw = 2
TextBox1.Text = Sheet1.Cells(rw,1)
Any help will be appreciated.
 
Your code will work if it is on the same sheet as the textbox, if as you say
it is being ignored without any errors I suspect the code is working, the
reference you are creating is to Row 2, Column 1, e.g. cell A2, have you
anything in cell A2? if not then the code will load "empty" and nothing
will change in the control.

You could fully specify the location of the Textbox, the following example
will work on the sheet code and a standard module.

Sub myCode()
Dim Rw As Integer
Rw = 2
With Sheet1
.TextBox1.Text = .Cells(Rw, 1)
End With
End Sub
 
Thanks for the info. NIgel.
Unfortunately your suggestion did not work and I felt that I had not given
enough information. My information is on a worksheet and I am trying to
take information from the worksheet and place it into textboxes on a userform
which is loaded from a standard module. When I tried your example Excel told
me it could not find Textbox1
I am struggling with this for the past four days so if you can spear the
time I would certainly appreciate your further help.
lyndon107
 
Ah, a UserForm! Use something like this to allocate the value (assuming the
UserForm is loaded into memory...

Form a standard module....

UserForm1.TextBox1.Value = Sheet1.Range("A2")

From the UserForm code

Me.TextBox1.Value = Sheet1.Range("A2")


--

Regards,
Nigel
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top