Loop - 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

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

mohadin

Well-known Member
Joined
Mar 22, 2015
Messages
1,393
Office Version
  1. 2013
Platform
  1. Windows
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
 
Solution

CJG19

New Member
Joined
Jul 12, 2021
Messages
30
Office Version
  1. 2010
Platform
  1. Windows
Rookie errors! Thank you! However now it is saying:

1640085807452.png
 

mohadin

Well-known Member
Joined
Mar 22, 2015
Messages
1,393
Office Version
  1. 2013
Platform
  1. Windows
Missed the last line???
VBA Code:
Loop
End Sub
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
63,243
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

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.
 

CJG19

New Member
Joined
Jul 12, 2021
Messages
30
Office Version
  1. 2010
Platform
  1. Windows
Apologies, being really thick! 🤦‍♀️
 

mohadin

Well-known Member
Joined
Mar 22, 2015
Messages
1,393
Office Version
  1. 2013
Platform
  1. Windows
You are welcome
And thank you for the feedback
Be happy and safe
 
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,492
Messages
5,832,008
Members
430,103
Latest member
BIGGAZ

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