change format

tpkelley_no

Board Regular
Joined
Oct 14, 2011
Messages
190
Office Version
  1. 2010
Platform
  1. Windows
I am looking for a way for VBA to look at column “D” and find the first five numbers from the left that equal 10210 (altus). And then look at column “B” and see if the number from the left equal 10700, 10800 and 10850. Then turn the cell numbers red if they are equal.
Example:
NameNames 2
1070510210
1070710210
1070010210
1085010210
1070010211
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
No need for VBA. This can be done pretty easily with Conditional Formatting.

Select cells B2 down to the end of your data.
Then, go to Conditional Formatting, select New Rule, then "Use a formula to determine which cells to format", and enter this formula:
Excel Formula:
=AND(D2=10210,OR(B2=10700,B2=10800,B2=10850))
then click on the Format button, go to the Font tab, and select your red Font color.

Here is the result:
1732546129080.png


If you really want VBA, you can turn on the Macro Recorder, and apply these Conditional Formatting steps.
Then you will have the VBA code that does this.
 
Upvote 0

Forum statistics

Threads
1,223,996
Messages
6,175,864
Members
452,678
Latest member
will_simmo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top