Loop - VBA

CJG19

New Member
Joined
Jul 12, 2021
Messages
40
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

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Hi
Mind the 2 points
1-
VBA Code:
 With Range("BK5:BK100").Interior
2-
VBA Code:
If ActiveCell.Value = "No" And ActiveCell.Offset(0, -1) > 0 And ActiveCell.Offset(0, 3) = 0 Then
 
Upvote 0
Solution
Rookie errors! Thank you! However now it is saying:

1640085807452.png
 
Upvote 0
Missed the last line???
VBA Code:
Loop
End Sub
 
Upvote 0
Note that EVERY Sub procedure in VBA needs to have an "End Sub" line at the very end of it.
It is not optional.
Its like punctuation at the end of a sentence.
 
Upvote 0
You are welcome
And thank you for the feedback
Be happy and safe
 
Upvote 0

Forum statistics

Threads
1,217,761
Messages
6,138,452
Members
450,139
Latest member
Sushmita Ramesh Kulkarni

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
Back
Top