fill Userform fields from Range given in InputBox

kerrss

New Member
Joined
Sep 26, 2002
Messages
2
I have the user select a Range with the following:
Sub InputRange()
Dim varRange As Variant
On Error Resume Next
Set varRange = _
Application.InputBox("Select all cells in the row you would like to update", Type:=8)
If IsObject(varRange) = False Then Exit Sub
'just to show the range has been selected
MsgBox varRange.Cells.Address
End Sub

I then want to take the values from the fields in this range and use them to fill in a UserForm.

Or, if I could just somehow reference the address of the first cell in the selected range, then I could pass that address thru to my form as a starting location and use the offset functions to fill the form - but, I don't know how to get the first cell address or pass it along for use in another bit of code.

I am really new to this, and would appreciate any help.

Thanks!
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

_Ken_

Board Regular
Joined
Jul 26, 2002
Messages
53
This may be a starting point for you.
This code will insert the contents of specific cells into TextBoxes in a UserForm. You will need a UserForm with 3 TextBoxes in this example
Private Sub UserForm_Initialize()
'Establish opening values for textboxes 1 to 3

TextBox1.Value = Sheets("Sheet1").Range("B1")
TextBox2.Value = Sheets("Sheet1").Range("B2")
TextBox3.Value = Sheets("Sheet1").Range("B3")

End Sub
 

kerrss

New Member
Joined
Sep 26, 2002
Messages
2
Thank you for your help.

I understand how to populate the form fields with cells in excel now, but I need the excel cells to be determined by the user by way of an InputBox and then I need to pass this reference to the bit of code you have shown me.

Any ideas?

Thanks.
 

Forum statistics

Threads
1,144,765
Messages
5,726,173
Members
422,659
Latest member
RGP268

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top