Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
self-sizing adv.filter criteria range | Excel Discussion (Misc queries) | |||
LINKEDRANGE function - a complement to the PULL function (for getting values from a closed workbook) | Excel Worksheet Functions | |||
Wrap Text Across Columns & Rows | Excel Discussion (Misc queries) | |||
Duplicate Range Names by worksheet | Excel Discussion (Misc queries) | |||
Help with using range names in sum function | Excel Worksheet Functions |