Solved

Excel VBA Conditional Highlighting

Posted on 2011-03-22
7
306 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
Comment Utility
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
Comment Utility
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
Comment Utility
here is an example file.

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

Michael
Book1.xls
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 1

Author Comment

by:jimtanner
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

763 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now