Xcel Highlight Macro


Posted by Peter Crymble on October 24, 2001 5:31 AM

Hi

Thanks Juan Pablo for your previous reply. I want to select & highlight the top few cells no matter what filter is applied e.g. row 60 on screen - needs highlighted if row 1. Current code is as suggested:

Range("B2:AV3").SpecialCells(xlCellTypeVisible).Select.Range("B2:AV2").Select
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With

However, with the filter applied I get the following error: "No cells found". Could you explain the code and how to get around this? Thanks so much for all the help so far - mrexcel is great!

PEter

============
ORIGINAL REPLY BELOW:

Change Range("A2:AV2") to

Range("A2:A40").SpecialCells(xlCellTypeVisible).Range("A1:AV2")

You need to adjust the first Range, A2:A40 to your needs.

Juan Pablo
======================
ORIGINAL QUESTION BELOW:




Posted by Juan Pablo on October 24, 2001 11:08 AM

Ok,

Range("B2:AV3").SpecialCells(xlCellTypeVisible).Select.Range("B2:AV2").Select
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With

I think the problem is with the first part range. If your ENTIRE RANGE, that is, all your data, is in A2:AV4506 then use this macro.

Range("B2:AV4506").SpecialCells(xlCellTypeVisible).Select.Range("A2:AV3").Select
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With

This will select the top two visible rows, from column A through AV.

Juan Pablo