A second Followup
A second followup.....
I found something that worked-- as a stand alone, with the code I'd shown in
my first followup above.
range("1:1", Selection.End(xlUp).Offset(1, 0)).EntireRow.Select
Once I got that to work-- in my general testing macro on all worksheets of
importance, I placed it in my pagesetup macro for a preliminary test run.
I got back an error stating that it's unable to set the PrintTitleRows
property of the PageSetUp Class.
I then tried setting my function that did work to a variable name, and it
then threw another error stating the object or with block was not set (the
original issue that was stumping me earlier).
So, I guess my next question would be-- can I set .PrintTitleRows to a
variable name? or does it require a constant row value such as "$1:$5"
I would've thought that even if the range was a function like:
range("1:1", Selection.End(xlUp).Offset(1, 0)).EntireRow.Select
it would've worked.
Any ideas at this point would be appreciated.
"Jim Cone" wrote:
Sub WhichOne()
'Returns the row number of the last row in selection.
Dim lngRw As Long
lngRw = Selection.Rows(Selection.Rows.Count).Row
MsgBox lngRw
End Sub
'--
'If the Selection is Range(B5:C10)then:
'Selection.Rows.Count ...returns the number 6.
'Selection.Rows(6) ...returns the last row in the selection (range object-cells B10:C10)
'Selection.Rows(6).Row ...returns the actual Excel row number or 10
'However, if you are just using the selection to define the Rows to Repeat at Top then
' ActiveSheet.PrintTitleRows = Selection.EntireRow.Address
--
Jim Cone
Portland, Oregon USA
"SteveDB1"
wrote in message
Ok, I've got the intitial elements working.
Do Until Selection.Interior.ColorIndex < -4142
ActiveCell.Offset(1, 0).Select
Loop
If Selection.Interior.ColorIndex < -4142 Then
'how do I define the last row selected?
'I tried the following and get a 1004 error.
range("$1: ActiveCell.EntireRow.cells()").Select
' I've also tried: range("$1:entirerow.cells()").select
' and range("$1:entirerow").select
' none of those work, and all throw a 1004 error.
End If
My goal now is to place the last row selected in the do loop into a
range().select (or a better choice) function so I can define the
PrintTitleRows element of PageSetUp
With ActiveSheet.PageSetUp
.PrintTitleRows = ""
.PrintTitleColumns = ""
End With
comnponent.
How would I accomplish this?
Thank you.
|