Consulting

Results 1 to 3 of 3

Thread: Solved: Comparing Cells

  1. #1
    VBAX Newbie
    Joined
    Aug 2009
    Posts
    4
    Location

    Smile Solved: Comparing Cells

    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:

    [VBA]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[/VBA]

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

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    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
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Newbie
    Joined
    Aug 2009
    Posts
    4
    Location
    No wonder mine didn't work! lol.. ...Thanks <again> very much for your help! I think I'm done with it now!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •