• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 6
  • Last Modified:

Macro to alternate row color based on values in column A

Does anyone know of a simple Macro to alternate the row colour in Excel when the value in column A changes?

The attached file shows an example of what I want to achieve.
0
HKFuey
Asked:
HKFuey
  • 2
1 Solution
 
NorieVBA ExpertCommented:
No file attached I'm afraid.
0
 
HKFueyAuthor Commented:
Screen Shot
0
 
Rob HensonFinance AnalystCommented:
You don't need VBA for that, you can use Conditional Formatting.

Insert a spare column in column A and enter the following formula, starting at row 2 and copy down as required:

=IF(B2=B1,A1,IF(A1=1,0,1))

This will then number each set of rows with 1 or 0. You can then use the 1 or 0 as a check value for Conditional Formatting.

See attached.

Column A can then be hidden if required.
Alternating-Format.xlsx
0
 
HKFueyAuthor Commented:
In the absence of any other solutions, you get the points!

I used some SQL to add a formatting column to the data output, then conditional formatting.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now