User input as a range

  • Thread starter Thread starter Shane
  • Start date Start date
S

Shane

Hello,
I need to get user input for a range of data and then assign this range to
array.

Anyone got any pointers..
Thanks S
 
Sub Tester9()
Dim varr As Variant
Dim rng As Range
On Error Resume Next
Set rng = Application.InputBox("select range with mouse", Type:=8)
On Error GoTo 0
If rng Is Nothing Then Exit Sub
varr = rng.Value
For i = 1 To UBound(varr, 1)
For j = 1 To UBound(varr, 2)
Debug.Print "Varr(" & i & ", " & j & ") = " & varr(i, j)
Next
Next
End Sub
 
there are 2 inputbox method's.
VBA's
Inputbox or VBA.inputbox

and Excel's Application.Inputbox

The latter boasts a refedit.. when Type =8

dim rng as range
on error resume next
set rng = Application.Inputbox("Select a Range..",type:=8)
on error goto 0
if rng is nothing then
exit sub 'cancelled
else
msgbox rng.address
endif



keepITcool

< email : keepitcool chello nl (with @ and .) >
< homepage: http://members.chello.nl/keepitcool >
 

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

Back
Top