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

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
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
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,214,909
Messages
6,122,189
Members
449,072
Latest member
DW Draft

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
Back
Top