Loop Conditional Formatting - VBA

CJG19

New Member
Joined
Jul 12, 2021
Messages
30
Office Version
  1. 2010
Platform
  1. Windows
Good Morning All,

I am trying to set up a loop conditional formatting with a pop up message, but something isn't working, can anyone help please?

1638779906282.png


If BO equals 0, BK is greater than 0 and BL says No then I want the cell in BL to turn red and a pop up massage to question 'Have we received final account certificate?' Once turned to yes it carries on to the next cell continues to the bottom of the table then goes back to the beginning. I have the following and I am unsure where I am going wrong:

Sub Final_Account_Cert()

'Remove cell fill colour
With Range("BK5:B100").Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Range("BL5").Select
'Begin the loop
Do Until ActiveCell.Value = ""
If ActiveCell.Value = No And ActiveCell.Offset(0, -1) > 0 And ActiveCell.Offset(0, 3) = 0 Then
'Display a message to the user
MsgBox "Have We Received Final Account Certificate?", vbInformation, "Invoice Detail"
'Format Invoice Code Cell to Red
ActiveCell.Interior.Color = 255
End If
ActiveCell.Offset(1, 0).Select
Loop

End Sub

I would appreciate any help!

TIA!

CJG19 :)
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

bebo021999

Well-known Member
Joined
Jul 14, 2011
Messages
1,090
Office Version
  1. 2016
Put below code in workheet_selectionchange even of "sheet" (not in module) to fire the range BL5:BL100 selection

VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Not Intersect(Target, Range("BL5:BL100")) Is Nothing Then
        If Target.Offset(, -1) > 0 And Target = "No" And Target.Offset(, 3) = 0 Then
        MsgBox "Have We Received Final Account Certificate?", vbInformation, "Invoice Detail"
        Target.Interior.Color = 255
        End If
    End If
End Sub
 

CJG19

New Member
Joined
Jul 12, 2021
Messages
30
Office Version
  1. 2010
Platform
  1. Windows
It doesn't seem to work:

1638794627652.png


1638794678926.png


Have I done something wrong?
 

CJG19

New Member
Joined
Jul 12, 2021
Messages
30
Office Version
  1. 2010
Platform
  1. Windows
Can anyone help please?
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,496
Messages
5,832,035
Members
430,105
Latest member
acemovingco

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top