ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   populate text boxes from data in worksheet (https://www.excelbanter.com/excel-programming/406278-populate-text-boxes-data-worksheet.html)

Lyndon107

populate text boxes from data in worksheet
 
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.


Nigel[_2_]

populate text boxes from data in worksheet
 
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
--

Regards,
Nigel




"Lyndon107" wrote in message
...
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.



Lyndon107

populate text boxes from data in worksheet
 
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

"Nigel" wrote:

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
--

Regards,
Nigel




"Lyndon107" wrote in message
...
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.



Nigel[_2_]

populate text boxes from data in worksheet
 
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




"Lyndon107" wrote in message
...
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

"Nigel" wrote:

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
--

Regards,
Nigel




"Lyndon107" wrote in message
...
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.





All times are GMT +1. The time now is 10:39 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com