Solved

Excel VBA Conditional Highlighting

Posted on 2011-03-22
7
309 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

756 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