Quick If = cell value

sassriverrat

Well-known Member
Joined
Oct 4, 2018
Messages
655
Quick question because my mind is blanking-

I have a macro that I'd like to have run if the value of Cell "A1" does not equal the value of Cell "B1". I'd like to insert the piece of code in the front part of the macro. If A1 does equal B1, a msgbox opens that says "hello".
p.s. Sheet is named "background"
Thanks
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Code:
Sub test()
'If Sheets("background").Range("A1") <> Sheets("background").Range("B1") Then
If Sheets("background").Range("A1") = Sheets("background").Range("B1") Then
MsgBox "Hello", vbOKOnly Or vbInformation, Application.Name
'..................... further code
End Sub
 
Upvote 0
haha oh man.... So I had simplified it a little and couldn't get it to work (thus posting).... I realized I fat-fingered my code and had >< instead of <>.... I guess that threw it

Thanks
 
Upvote 0

Forum statistics

Threads
1,214,642
Messages
6,120,701
Members
448,980
Latest member
CarlosWin

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