get cell value to textbox

C

Christy

Great forum - thanks to all for making it possible

I am trying to use the value a user will type into a
textbox on one userform to determine the value that will
be displayed in a textbox on another userform.

I know the range of numbers the user will type and I have
set up the underlying sheet to have the information I
want to retreive in the row corresponding to that number.
ie: user types 50, the answer I want to disply will be in
row 50.

There are 2 option button also whose choice combination
will determine which column to get the info from.

I have used code like: (this is in it's own module)

Sub toRunifOB2true ()
If UserFormEntry.OptionButton1 = True Then

If UserFormEntry.TextBox1.Value = 51 Then
UserFormCorrection.TextBox1.Value = Range("e51").Value

If UserFormEntry.TextBox1.Value = 52 Then
UserFormCorrection.TextBox1.Value = Range("e52").Value

then, in the click procedure of the button on the entry
userform I test the condition of the other optionbutton
and call the appropriate sub.

This seems to work of but many lines of code are required
to cover all the choices.

Anyone have a suggestion how I can loop this or something
to do this better?

My object names are also very long, can I define them to
something shorter then use the shorter name?

Thanks in advance for your help!
 
R

Rocky McKinley

Hi Christy, perhaps something like...

If UserFormEntry.OptionButton1 = True and
isnumeric(UserFormEntry.TextBox1.Value) Then
UserFormCorrection.TextBox1.Value = Range("E" &
UserFormEntry.TextBox1.Value ).Value
End If
 

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