Dynamic Range Selection
Assumes cells are not empty in Column D for as far down as you want to
check.
Dim lastRow as Long
Dim rng as Range
lastRow = 0
set rng = Range("D7")
Do while not isempty(rng)
if rng.interior.colorIndex = 35 then
lastRow = rng.row
end if
set rng = rng.offset(1,0)
Loop
Set rng = Range(Range("D7"),Cells(lastRow,4)).Resize(,2)
rng.select
Can't guarantee that 35 is the light green you speak of.
Select one of the cells and run this
Sub ShowColorIndex
msgbox ActiveCell.Interior.ColorIndex
End Sub
If that number doesn't show 35, then change my code to match that number.
--
Regards,
Tom Ogilvy
"Todd Huttenstine" wrote in message
...
Good afternoon!
I need to print a specific range of data but first I need
to know the cells that comprise the range. I know the
range will always start with cell D7 and will only go
through ColumnE. So now all I need is to know how far
down in rows to select. In order to do this I need for
Excel to look in ColumnD and see what the last cell is
that contains the background color light green. For
instance lets say the last cell in ColumnD that contains
the background color light green is cell D75. If this is
the case I need for it to select the range D7:E75.
What is the code that will do this?
Thank you
Todd Huttenstine
|