PDA

View Full Version : Solved: Comparing Cells



mmwtx
08-21-2009, 07:34 AM
I have a spreadsheet with a VB macro that runs a series of checks and balances. My last step is that I want to compare two cells "J67" and "J68". If they are the same, I want the code to continue to run. But if they are not the same amount, I want a msgbox to pop up informing the user that there is an imbalance and asking them if that's ok? If they click YES, then the code continues. If they click NO, then they go to that spot to fix their error. I'm having trouble getting this to work for some reason and think I don't have the IF statements correct.

Here's what I have so far:

If Range("J67") = _
Range("J68") Then
If MsgBox("Total Due and Amount Paid Do Not Match. Is this OK?", vbYesNo) = vbNo Then Exit Sub
Range("J68").Select

End If

I am a newbie and would appreciate any help/advice you can give. Thank you!

Bob Phillips
08-21-2009, 08:09 AM
If Range("J67").Value <> Range("J68").Value Then
If MsgBox("Total Due and Amount Paid Do Not Match. Is this OK?", vbYesNo) = vbNo Then

Range("J68").Select
Exit Sub
End If
End If

mmwtx
08-21-2009, 09:28 AM
No wonder mine didn't work! lol.. :blush ...Thanks <again> :bow:very much for your help! I think I'm done with it now!