LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default VB Code Highlight Rows Based on Color Index

Hi Jay,

'-----------------
Thanks for the follow-up. Yes, I see that Bob's approach properly limits
the highlights to the rows in the data range. It also highlights the
entire
worksheet row which is fine, but I thought I'd offer the OP an alternative
that also limits the highlighting to the columns in the data range.

Regarding your concern, I opted for the UsedRange object to improve
portability (the procedure is independent of data location). Based on
standard design assumptions (no superfluous data outside the data range - as
in Bob's example), I've found the procedure to be reliable in testing.

My testing may have missed something or you may have something more specific
(or a generality) in mind; if so, let us know.
'-----------------

A potential problem with the use of the UsedRange
property is that it may overstate what the user perceives
as the worksheets data boundaries.

In this connection see Debra Dalgleish's advice on resetting
the UsedRange at:

http://www.contextures.com/xlfaqApp.html#Unused

To limit the number of columns highlighted, a more reliable
method might be to return the last data column using, for
example, a function like:

'==========
Function LastCol(SH As Worksheet, _
Optional rng As Range) _
As Long
If rng Is Nothing Then
Set rng = SH.Cells
End If

On Error Resume Next
LastCol = rng.Find(What:="*", _
After:=rng.Cells(1), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Column
On Error GoTo 0
End Function
'<<==========


---
Regards,
Norman


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
highlight subtotal rows with a fill color Deb Raskob Excel Worksheet Functions 1 August 9th 08 06:30 PM
Color Index Code, is there any thing like that? wilchong via OfficeKB.com New Users to Excel 3 May 22nd 08 01:56 PM
Should be able to color code or highlight Excel worksheet tabs. brie_01 Excel Worksheet Functions 3 August 17th 06 03:42 PM
Range based on interior color index? garle Excel Programming 4 January 25th 06 02:24 PM
excel: How can I color code rows based on a value in a cell? Parker1333 Excel Discussion (Misc queries) 2 February 1st 05 10:37 PM


All times are GMT +1. The time now is 06:32 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright 2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"