Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 396
Default 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 ***
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default 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 ***



Reply
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
Change the colour of numbers in a cell if the number is negative bryno Excel Worksheet Functions 3 March 5th 08 09:27 PM
Change text colour according to number R.Demandt Excel Worksheet Functions 2 November 28th 06 08:24 AM
How do i format cell to change colour as the number increases Lanre Bex Ayoade Excel Programming 10 September 1st 06 04:26 PM
change cell colour if value in column = x?? Simon Lloyd[_700_] Excel Programming 5 March 23rd 06 07:00 AM
Change cell Colour when a number of days have been passed SR7133 Excel Discussion (Misc queries) 4 March 1st 06 10:49 PM


All times are GMT +1. The time now is 06:28 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"