PrintTitleRows 2
It actually works-- of course it does, you did it <vvvvbg.
However, as with my immediately previous post, I've found that I'm unable to
set the PrintTitleRows using a range function, or a variable.
I agree with the 25000 rows. Thankfully, in all of my cases encountered so
far (which is why I chose this way-- if it was in the few to several dozens
even, I'd be choosing another way), the farthest down the first row that's
colored is row 18. And I think that's only one or two files-- out of the 700
to 800 we have, I've done some 40 to 60% of those. Most files range from 5 to
14 rows.
Thus, I'm now back to-- can I set my PrintTitleRows by use of anything other
than a constant? I.e., .PrintTitleRows = "$1:$12"
because it's thrice rejected
ActiveSheet.PageSetUp.PrintTitleRows = Range("A1", Cells(i, 1))
and
Set rngTop = Range("A1", Cells(i, 1))
ActiveSheet.PageSetUp.PrintTitleRows = rngTop
"Jim Cone" wrote:
I think this is what you want?...
'--
Sub TopStuff()
' always use a Long for a row number
Dim i As Long
Dim rngTop As Range
i = 1
' specify the starting point.
Range("A1").Select
Do Until Selection.Interior.ColorIndex < -4142
ActiveCell.Offset(1, 0).Select
i = 1 + i
Loop
Set rngTop = Range("A1", Cells(i, 1))
MsgBox rngTop.Address
End Sub
'--
'In general, selecting cells is not good practice.
'However, in place of the last two lines you could use...
Range("A1", Cells(i, 1)).Select
MsgBox Selection.Address
--
Also, there is more than one way to code the above.
If the first colored cell was at row 25000,
then code execution might take longer than you want.
'--
'Further, you can only make a selection on the active sheet.
'That is why you should select a sheet first,then make a selection.
'In your case everything takes place on the active sheet, so
'no sheet selection is necessary.
'--
Jim Cone
Portland, Oregon USA
"SteveDB1"
wrote in message
Good morning Jim.
Thank you for the response yesterday evening.
At this point, I've got a do until loop that iterates through all of the
first few rows that are not filled with an interior color. When it finds a
row that is ...interior.colorindex <-4142 it stops.
My next goal is to select the range from the start row, to the last row in
my loop-- the i-th row--so that I can perform the task of selecting those
rows, then fulfill a subsequent task.
It's the selection of those rows that's stumping me.
Yesterday afternoon after I'd posted this, I finally found the code to make
a selection, but it either selected the i-th row, downward to the 17th row
below the i-th row, or skipped some rows and then selected i- number of rows.
I know that it's something simple, but so far I haven't found it.
My existing code so far is:
----------------------------------
Dim i As Integer
i = 1
Do Until Selection.Interior.ColorIndex < -4142
ActiveCell.Offset(1, 0).Select
i = 1 + i
Loop
If Selection.Interior.ColorIndex < -4142 Then
'everything works until here.
'this next function does not work.
ActiveSheet.Select 'I chose this because the help file said I had to.
Selection.range("a1", Row.cell(i)).Select
End If
---------------------------------
for whatever reason, instead of selecting cell a1, it treats the i-th row as
a1, and then dropped down 17 more rows, and selected all of them.
I specifically am seeking to select row 1, and then include row 1 to the
i-th row.
I hope that makes my thinking clearer. If not, please let me know, and I'll
try further to clarify.
Again, I really appreciate your time and assistance.
|