LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Need Help: Dynamic Range

I need help changing the: For Each rng In Range("B2:B5000") to a dynamic
statement that looks for the last column/row used in the sheet.

Thanks in advance for the help.

Sub Green_Bar()
Dim rng As Range
Dim OldVal As Variant
Dim Gray As Boolean
Gray = True
OldVal = Range("B2").Value

For Each rng In Range("B2:B5000") ' WANT TO BE ABLE TO MAKE THIS DYNAMIC

If rng.Value = OldVal Then
If Gray Then
rng.EntireRow.Interior.ColorIndex = 2
Else
rng.EntireRow.Interior.ColorIndex = 4
End If
Else
OldVal = rng.Value
Gray = Not Gray
If Gray Then
rng.EntireRow.Interior.ColorIndex = 2
Else
rng.EntireRow.Interior.ColorIndex = 4
End If
End If
Next
End Sub


 
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
Dynamic range Eva Excel Worksheet Functions 0 December 15th 09 05:28 PM
Dynamic Range Dave Excel Worksheet Functions 1 April 8th 08 04:21 AM
Dynamic range pelachrum Excel Discussion (Misc queries) 5 July 2nd 06 09:27 PM
Dynamic Range with unused formula messing up x axis on dynamic graph [email protected] Charts and Charting in Excel 2 February 2nd 06 08:02 PM
Excel 2000 VBA - Set Print Range in dynamic range sub_pop[_5_] Excel Programming 2 July 27th 04 08:01 PM


All times are GMT +1. The time now is 08:32 AM.

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

About Us

"It's about Microsoft Excel"