cell value to text box?

  • Thread starter Thread starter tomro1
  • Start date Start date
T

tomro1

i'm having problems with getting a cell value into a textbox in a
userform.

my problem is that i am trying to get a cell value in a worksheet
displayed into a textbox in my userform with vba but can't find the
right code.

any ideas?

:)
 
Try this in the event procedure that you activate to transfer the value

Lets say your UserForm = UserForm1
and TextBox = TextBox1
and Sheet = Sheet1

UserForm1.TextBox1.Value = Sheet1.Range("A1").Value
 
KellTainer said:
UserForm1.TextBox1.Value = Sheet1.Range("A1").Value


it still has a problem with "sheet1", he doesn't recognizes it.

i also have tried

textbox1.value = sheets("sheet1") range("a1").value

but also doens't work
 
hmm, you have to modify the code to suit your needs. just change the
different variables to suit your application.
 
It is possible to change the name of the sheet in the VBE environment
under the properties of the worksheet object. This name is different
from the name you give a sheet via the tab in excel. Normally the first
sheet can always be referenced as "sheet1" unless the internal name has
been altered. To check this go to the VBE and look at the properties
box for the sheet you need to work with. The first property listed will
be (name) and it's value is what you want to use in place of "sheet1".
In the future I would avoid changing this name property unless you
really need to (if that turns out to be the problem)

Hope this helps.
 
It is possible to change the name of the sheet in the VBE environment
under the properties of the worksheet object. This name is different
from the name you give a sheet via the tab in excel. Normally the
first
sheet can always be referenced as "sheet1" unless the internal name
has
been altered. To check this go to the VBE and look at the properties
box for the sheet you need to work with. The first property listed
will
be (name) and it's value is what you want to use in place of "sheet1".
In the future I would avoid changing this name property unless you
really need to (if that turns out to be the problem)

Hope this helps.
[/url]
[/QUOTE]

i used the proper names but the formula didn't work, so tried something
else, and nog its works:cool:


Worksheets("sheet1").Activate
Range("a1").Select
TextBox1.Text = ActiveCell.Value
 
try this:
UserForm1.TextBox1.Value =
excel.application.activewindow.activesheet.range.("A1").Value

It is possible to change the name of the sheet in the VBE environment
under the properties of the worksheet object. This name is different
from the name you give a sheet via the tab in excel. Normally the
first
sheet can always be referenced as "sheet1" unless the internal name
has
been altered. To check this go to the VBE and look at the properties
box for the sheet you need to work with. The first property listed
will
be (name) and it's value is what you want to use in place of "sheet1".
In the future I would avoid changing this name property unless you
really need to (if that turns out to be the problem)

Hope this helps.
[/url]

i used the proper names but the formula didn't work, so tried something
else, and nog its works:cool:


Worksheets("sheet1").Activate
Range("a1").Select
TextBox1.Text = ActiveCell.Value
[/QUOTE]
 

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