Solved

Conditional Formatting Activated, VBA

Posted on 2011-02-10
6
261 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
  • 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
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!

 

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

679 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