Solved

Excel VBA Conditional Highlighting

Posted on 2011-03-22
7
311 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

732 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