Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 18th, 2016, 04:32 PM
Registered User
 
Join Date: Jan 2016
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default VbA change colour cells based on cells values in oother sheets

Hello,

I would like to write a VBA macro with a button command to change the background colour of cells in the last active row in a range in sheet 2 Range (A1: A8) only if the cells in a range (A1:A5) in sheet 1 are the same as in sheet 2 .

As follow:

Sheet 1
A1 A2 A3 A4 A5
1 2 3 4 5

Sheet 2
A1 A2 A3 A4 A5 A6
12 3 1 7 2 9

If value in A1 sheet 1 in range A1: A6 in sheet 2 colour red else the blanks
If value in A2 sheet 1 in range A1: A6 in sheet 2 colour orange else the blanks
If value in A1 sheet 1 in range A1: A6 in sheet 2 colour yellow else the blanks
If value in A1 sheet 1 in range A1: A6 in sheet 2 colour blue else the blanks
If value in A1 sheet 1 in range A1: A6 in sheet 2 colour green else the blanks

Example:
In our example: A3 background in sheet 2 would be red
In our example: A5 background in sheet 2 would be orange
In our example: A2 background in sheet 2 would be yellow
The other cells in sheet 2 ( A 1, A4, A6 ) would stay the same

Can anyone help?

Thanks in advance

Bruno
 
Old January 26th, 2016, 08:14 AM
Authorized User
 
Join Date: Oct 2015
Posts: 48
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Hi Bruno,
I think some aspects of your post contradict others but I have the picture.

Sheet 1 has values and sheet 2 has the look-up Range you colour based on.
For each myValue in myValues
For each myLookup in myLookups
If if myValue = my lookup then
MyValue.color = green
And so on and so on.
__________________
Nostalgia 4 Infinity





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to insert or delete the cells based on a value in another cell? p959834 Excel VBA 0 May 14th, 2014 05:43 AM
Converting empty cells in Excel to null cells for importing into Access rmccafferty Excel VBA 0 August 30th, 2012 03:07 AM
Unlocking Cells Based Upon Value of Another Cell Graviz Excel VBA 1 May 7th, 2012 11:58 AM
colour sum conditionally formatted cells Mark Bristoll Excel VBA 0 November 20th, 2010 09:40 AM
how to read data form a file using vba to change cells in excel fuze Excel VBA 2 April 6th, 2009 11:25 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.