#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 29
Default Range

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.

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Range

Is is single area 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 myRng.Address & vblf _
& myrng.row & vblf _
& myrng.cells(myrng.cells.count).row
End If

=======
If you're going to loop through those rows:

dim myRow as 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
for each myrow in myrng.rows
msgbox myrow.address
next myrow
end if

Nimish wrote:

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.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
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.



  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 29
Default Range

Dave,

This is a single range, but the key is that I have a macro that reads:

For CopieNumber = 2 To 35
With ActiveSheet
.PageSetup.LeftHeader = Cells(CopieNumber, "A").Value
.Range("A:A").AutoFilter Field:=1,
Criteria1:=Cells(CopieNumber, "A").Value
'Print the sheet
.PrintOut preview:=True
.AutoFilterMode = False
End With
Next CopieNumber
Application.ScreenUpdating = True


for the "CopieNumber" range, I want to sub 2 and 35 for "BEginning of
the selected range" ro "end of the selected range". The range is
continuous.

-Nimish


Dave Peterson wrote:
Is is single area 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 myRng.Address & vblf _
& myrng.row & vblf _
& myrng.cells(myrng.cells.count).row
End If

=======
If you're going to loop through those rows:

dim myRow as 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
for each myrow in myrng.rows
msgbox myrow.address
next myrow
end if

Nimish wrote:

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.


--

Dave Peterson


  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Range

dim FirstRow as long
dim Lastrow as long

with selection
firstrow = .row
lastrow = .cells(.cells.count).row
end with

for copienumber = firstrow to lastrow

Nimish wrote:

Dave,

This is a single range, but the key is that I have a macro that reads:

For CopieNumber = 2 To 35
With ActiveSheet
.PageSetup.LeftHeader = Cells(CopieNumber, "A").Value
.Range("A:A").AutoFilter Field:=1,
Criteria1:=Cells(CopieNumber, "A").Value
'Print the sheet
.PrintOut preview:=True
.AutoFilterMode = False
End With
Next CopieNumber
Application.ScreenUpdating = True

for the "CopieNumber" range, I want to sub 2 and 35 for "BEginning of
the selected range" ro "end of the selected range". The range is
continuous.

-Nimish

Dave Peterson wrote:
Is is single area 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 myRng.Address & vblf _
& myrng.row & vblf _
& myrng.cells(myrng.cells.count).row
End If

=======
If you're going to loop through those rows:

dim myRow as 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
for each myrow in myrng.rows
msgbox myrow.address
next myrow
end if

Nimish wrote:

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.


--

Dave Peterson


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
self-sizing adv.filter criteria range BorisS Excel Discussion (Misc queries) 3 September 24th 06 01:30 PM
LINKEDRANGE function - a complement to the PULL function (for getting values from a closed workbook) [email protected] Excel Worksheet Functions 0 September 5th 06 03:44 PM
Wrap Text Across Columns & Rows Michael Excel Dude Excel Discussion (Misc queries) 1 September 4th 06 02:14 AM
Duplicate Range Names by worksheet FlaAl Excel Discussion (Misc queries) 0 May 24th 06 05:14 PM
Help with using range names in sum function soteman2005 Excel Worksheet Functions 2 November 28th 05 04:43 PM


All times are GMT +1. The time now is 11:35 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"