Thread: Range
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default Range

Set myRng = Nothing
On Error Resume Next
Set myRng = Application.InputBox(Prompt:="Select a range!", Type:=8)
On Error GoTo 0

If myRng Is Nothing Then
'user hit cancel
Else
MsgBox "First row is " & myRng.Row & ", " & vbNewLine & _
"Last row is " & myRng(myRng.Count).Row
End If

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Nimish" wrote in message
oups.com...
I want to take a range that I have inputted from a input box and get
row ID numbers. the range is written as follows:

Set myRng = Nothing
On Error Resume Next
Set myRng = Application.InputBox(Prompt:="Select a range!", Type:=8)
On Error GoTo 0

If myRng Is Nothing Then
'user hit cancel
Else
MsgBox myRng.Address
End If

I want to take this range and identify the first and last row number
(actual row ID in excel).

I am having trouble with invalid code when I make variables to identify
this. This is going into a For statement to run code from.