Solved

Conditional Formatting Activated, VBA

Posted on 2011-02-10
6
265 Views
Last Modified: 2012-08-14
I've scoured the web for an answer to this question but came up with nothing. I'm trying to have a message box popup if a conditional format is activated on a cell, each cell has 3 different conditional formats, each with a different validation message. Since conditional formatting does not set the interior property, I cannot use ColorIndex as a criteria. Below is what I have, I just need to replace the "Interior.ColorIndex" with, whichever, if any function lets me select the conditional formatting criteria (which is colors.) Below is a snapshot of what I have - Thanks much.

If Cells(29, 5).Interior.ColorIndex = 3 And Cells(43, 2).Interior.ColorIndex = 6 Then
MsgBox "-Line 1 of Message" & vbCrLf & _
        "-Line 2 of message.", vbOKCancel, "Title
       
ElseIf Cells(43, 2).Interior.ColorIndex = 6 Then
MsgBox "Please provide an explanation for question 5a."
0
Comment
Question by:shoaibs
[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
  • 3
  • 3
6 Comments
 
LVL 24

Expert Comment

by:StephenJR
ID: 34865242
Use the underlying CF criteria.
0
 

Author Comment

by:shoaibs
ID: 34865271
I would, but they are quite complex with nested if's etc., I would hate to have to reinput them all into VBA. Any other ideas?
0
 
LVL 24

Expert Comment

by:StephenJR
ID: 34865299
There is no other way. If you post a workbook we can get an idea of what you're doing.
0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 

Author Comment

by:shoaibs
ID: 34865450
Thanks for the advice. Below is one of the validation formulas, and my conversion to VBA- but this time around it did not work, any idea of what I'm doing wrong in the below example?

=IF(AND(J41="yes",ISBLANK(B43)),TRUE,FALSE)

Private Sub worksheet_deactivate()
If Cells(43, 2).Value = Null And Cells(10, 41).Value = "Yes" Then
MsgBox "-Please provide an explanation for question 5a.", vbOKCancel
End If
End Sub

Thanks again.
0
 
LVL 24

Accepted Solution

by:
StephenJR earned 500 total points
ID: 34865501
Try this:

Private Sub worksheet_deactivate()
If IsEmpty(Cells(43, 2)) And Cells(41, 10).Value = "Yes" Then
MsgBox "-Please provide an explanation for question 5a.", vbOKCancel
End If
End Sub
0
 

Author Comment

by:shoaibs
ID: 34865506
Actually, replaced the null with "" and it worked. Thanks again for all of your help.
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

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
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 use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

632 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