ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   For every new number in Column A - change row colour (https://www.excelbanter.com/excel-programming/376527-every-new-number-column-change-row-colour.html)

Les Stout[_2_]

For every new number in Column A - change row colour
 
Hi all, i am able to change every other line color but i need to do it a
bit differently with VBA. For every new number in column "A" i need to
alternate yellow and no color. see example below.

gAMS No gAMS Description
AAB05U HA-Getriebe--- Yellow
AAB05U HA-Getriebe--- Yellow
AAF15U BlowBy-Einleitung in Luftfuehrung N54--- White
AAJ28U Getriebeoelkuehlerruecklaufleitung---Yellow
AAK45U Getriebekabelbaum N46 OL RL--- White
AAK78U Schalthebeltilger PL-2 M47---Yellow
AAW81T QUAKO AFS Lenkhilfekuehler PL2--- White
AEX31U QUAKO- Kopfsstuetze PL2 Leder ohne Watte--- Yellow
AEX31U QUAKO- Kopfsstuetze PL2 Leder ohne Watte--- Yellow
AEY08U Quako: Cost Down Massnahme Radio Stufe 1---White

Any assistance with code would be appreciated...


Les Stout

*** Sent via Developersdex http://www.developersdex.com ***

Gary Keramidas

For every new number in Column A - change row colour
 
not saying this is the best way, but seems to work with your data. i just copied
what you posted and pasted it in A1 and replicated some down to A20.
someone may have a simpler solution.

Sub test()
Dim cell As Range
Dim cntr As Long
cntr = 0
For Each cell In Range("a2:A20")
If cell.Value = cell.Offset(-1, 0).Value Then
If cntr Mod 2 = 1 Then
cell.Offset(-1, 0).Interior.ColorIndex = 6
Else
cell.Offset(-1, 0).Interior.ColorIndex = 2
End If
Else
cntr = 1 + cntr
If cntr Mod 2 = 1 Then
cell.Offset(-1, 0).Interior.ColorIndex = 2
Else
cell.Offset(-1, 0).Interior.ColorIndex = 6
End If
End If
nxt:
Next
End Sub

--


Gary


"Les Stout" wrote in message
...
Hi all, i am able to change every other line color but i need to do it a
bit differently with VBA. For every new number in column "A" i need to
alternate yellow and no color. see example below.

gAMS No gAMS Description
AAB05U HA-Getriebe--- Yellow
AAB05U HA-Getriebe--- Yellow
AAF15U BlowBy-Einleitung in Luftfuehrung N54--- White
AAJ28U Getriebeoelkuehlerruecklaufleitung---Yellow
AAK45U Getriebekabelbaum N46 OL RL--- White
AAK78U Schalthebeltilger PL-2 M47---Yellow
AAW81T QUAKO AFS Lenkhilfekuehler PL2--- White
AEX31U QUAKO- Kopfsstuetze PL2 Leder ohne Watte--- Yellow
AEX31U QUAKO- Kopfsstuetze PL2 Leder ohne Watte--- Yellow
AEY08U Quako: Cost Down Massnahme Radio Stufe 1---White

Any assistance with code would be appreciated...


Les Stout

*** Sent via Developersdex http://www.developersdex.com ***





All times are GMT +1. The time now is 10:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com