MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Set TextBox value to active range


Posted by Todd P on June 06, 2001 12:24 PM

I would like to know how to set the value of a textbox to a range of cells that I select in Visual Basic; very similar to how the functions in Excel work.

I am currently typing in the ranges of the cells into my forms and it would be much easier if I could simply select the TextBox to enter the data into and then select the range off of my Excel sheet. Any help is appreciated.


Posted by cpod on June 06, 2001 12:51 PM

You could just put something like this into the Enter for Double Click event of your textbox:

UserformName.TextboxName = Selection.Address

Posted by Todd P on June 08, 2001 7:50 AM

Thanks for the help. I got that to work for entering one value when previously highlighted. My followup question would be - How can I go from the active form back to the Excel sheet to select another range to enter into my TextBox? I have not been able to find anything to deactivate my form to allow me to select a different range to use as input. Thanks.

: I would like to know how to set the value of a textbox to a range of cells that I select in Visual Basic; very similar to how the functions in Excel work.