Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Excel VBA Conditional Highlighting

Posted on 2011-03-22
7
Medium Priority
?
315 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:Michael Fowler
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:Michael Fowler
ID: 35196222
here is an example file.

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

Michael
Book1.xls
0
Independent Software Vendors: 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 1500 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

688 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