Assigning cell contents to a textbox in a User Form

J

Jack Gillis

Under Excel 2003 and with the help of many here in this NG, I have
designed a User Form to display the contents of some of the cells in a
workbook.

The way I did it was, in general, like this:



txtTextBoxName.Text = Sheets("SheetName").Cells(6, 2).Text and so forth
for each textbox and cell.

It works fine until I insert a column or row in the sheet and the info I
want in the TextBoxName is no longer in 6,2.

Is there anyway I can use relative addressing or something like it to
avoid this problem? I have tried assigning a name to each cell I want
to show in the form but can't make that work.

As you probably can tell, I am in over my head here and will appreciate
any help.

Thank you
 
D

Dave Peterson

I'm not sure what you mean by relative addressing--can you define how the data
should be picked up from the worksheet.

And I'm not sure why using range names didn't work, either.

txtTextboxname.text = sheets("sheetname").range("NameCell").text

seems like it should work ok.
 
J

Jack Gillis

Dave Peterson said:
I'm not sure what you mean by relative addressing--can you define how
the data
should be picked up from the worksheet.

And I'm not sure why using range names didn't work, either.


Heh, Heh! I am. And I too embarrased to say why but chalk it up to
operator error pointed out by the code you provided below.

Thank you very much.
 

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

Top