Trouble with a loop

CJG19

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

After hours of trying to get the below to work, I realise I need a little more help on the below:

1643014850440.png


To my mind BM with £12,141 and BN £0 should pop up with a message box and turn red in BO "No" but it isn't working. I can't for the life of me work out why, can someone help please?

TIA!!

CJG19
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Does column BN contain formulas?
One possibility is that the 0.00 you see in BN is actually something like 0.0000002 and therefore is not zero.

In a blank cell put this formula pointed at the row in question & see what it returns

=BN15=0
 
Upvote 0
You're checking for "No", but your BO-column is filled with "NO". Those are not the same.
 
Upvote 0
Solution
Perfect, thank you so much!

Another quick question, is there a way of making the MsgBox a yes/no?
 
Upvote 0
vbYesNo instead of vbInformation. To "save and use" the user answer and do something with it you can do:

VBA Code:
response = MsgBox "whatever", vbYesNo, "whatever"
If response = vbYes Then
    'do something
End If
 
Upvote 0
Thanks Engberg!

I am trying to get - if the answer is yes, change the active cell to Yes and turn green - final query I promise!
1643022479425.png


Thank you for all of your help so far!!

CJG19
 
Upvote 0
@CJG19
In future, please post your actual code not a picture of it. That way helpers can copy it to test with, which cannot be done from an image.
My signature block below has more information about posting code using code tags - as @Engberg has done
 
Upvote 0
Apologies, please see below:

Thanks @Engberg!

I am trying to get - if the answer is yes, change the active cell to Yes and turn green - final query I promise!

VBA Code:
Sub Final_Account_Cert()

Range("BO5").Select
'Begin the loop
Do Until ActiveCell.Value = ""
If ActiveCell.Value = "NO" And ActiveCell.Offset(0, -2) > 0 And ActiveCell.Offset(0, -1) = 0 Then
'Display a message to the user
MsgBox "Have We Received Final Account Certificate?", vbYesNo, "Thank you"
'Turn cell green and change text to Yes
If AnswerYes = vbYes Then
ActiveCell.Value = "YES"
ActiveCell.Interior.Color = 65280
End If
'Format Invoice Code Cell to Red
ActiveCell.Interior.Color = 255
End If
ActiveCell.Offset(1, 0).Select
Loop
End Sub

Thank you for all of your help so far!!

CJG19
 
Upvote 0
Makes cell green if answer is Yes, makes cell red if answer is No:

VBA Code:
Sub Final_Account_Cert()

Range("BO5").Select
'Begin the loop
Do Until ActiveCell.Value = ""
    If ActiveCell.Value = "NO" And ActiveCell.Offset(0, -2) > 0 And ActiveCell.Offset(0, -1) = 0 Then
        'Display a message to the user
        answer = MsgBox("Have We Received Final Account Certificate?", vbYesNo, "Thank you")
        If answer = vbYes Then
            ActiveCell.Value = "YES" 'Turn cell green and change text to Yes
            ActiveCell.Interior.Color = 65280
        ElseIf answer = vbNo Then
            ActiveCell.Interior.Color = 255 'Format Invoice Code Cell to Red
        End If
    End If
    ActiveCell.Offset(1, 0).Select
Loop

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,789
Messages
6,121,590
Members
449,039
Latest member
Arbind kumar

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