Solved

Excel VBA Conditional Highlighting

Posted on 2011-03-22
7
308 Views
Last Modified: 2012-06-27
Hi,

I have a column with occasional empty cells. I wish to highlight the cell to the imediate right of the empty cell.
e.g If (I:3) is empty I want to highlight (J:3)

Thank you
0
Comment
Question by:jimtanner
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 23

Expert Comment

by:Michael74
ID: 35196201
This link has a good tutorial for excel 2003 and earlier
http://www.cpearson.com/excel/cformatting.htm

and here is one for 2007+
http://www.howtogeek.com/howto/microsoft-office/using-conditional-cell-formatting-in-excel-2007/

Michael
0
 
LVL 7

Expert Comment

by:Jignesh Thar
ID: 35196215
select column J,
Go to Home - Conditional formatting,
Select new rule - Using formula
Use =ISBLANK($I1) formula and apply this to =$J:$J

See attached
select-column-J.xlsx
0
 
LVL 23

Expert Comment

by:Michael74
ID: 35196222
here is an example file.

I selected the range, then under conditional formatting iused the formula =isblank(I1)

Michael
Book1.xls
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 1

Author Comment

by:jimtanner
ID: 35196346
Hi

I really need code for this.
Neglected to mention that J only needs to be highlighted if it is = or greater than 100.
If (I:5)is blank and (J:5) is >or= 100 then highlight (J:5) otherwise do nothing.

Thank you for your help.
0
 
LVL 7

Accepted Solution

by:
Jignesh Thar earned 500 total points
ID: 35196377
Do you really need VBA code while this can be easily achieved through conditional formatting?

you can use =AND(ISBLANK($I1),$J1>=100) formula. See attached file.
select-column-J-1-.xlsx
0
 

Expert Comment

by:puneetd
ID: 35196428
Select J3 cell
Go to Format | Conditional Formatting. In Excel 2007, click Conditional Formatting on the Home tab.

Choose Formula Is from the Condition 1 drop-down list. In Excel 2007, click New Rule and then click Use A Formula To Determine Which Cells To Format.

Enter the following formula:=ISBLANK(I3)
Click the Format button.
Click on the Patterns tab, select blue, and click OK. In Excel 2007, go to the Fill tab, choose blue under Background color (Figure B), and click OK.
Click OK.

You can drag the J3 cell if you need to implement the same conditional formatting for multiple cells, ie. for the other cells in column.
0
 
LVL 1

Author Closing Comment

by:jimtanner
ID: 35198258
Thanks for the help everyone.

Code as follows

Sub Highlight()

    Columns("J:J").Select
    Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=AND(ISBLANK($I1),$J1>=100)"
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Selection.FormatConditions(1).Interior
        .PatternColorIndex = xlAutomatic
        .Color = 65280
        .TintAndShade = 0
    End With
    Selection.FormatConditions(1).StopIfTrue = True
    Range("A1").Select
End Sub
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question