Check that 2 cells = the same value

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,226
Office Version
  1. 2007
Platform
  1. Windows
Evening,
I am using the working code supplied below.

I would like to add some kind of check value code after the supplied code below has run.
So in this particular code, values are copied from sheet name EXPENSES1 & pasted to sheet name EXPENSES2

This would be the additional code required please.
Once pasted to sheet EXPENSES2 the code would need to make sure that the value in cell K32 on EXPENSES2 is the same value as cell M1 on sheet EXPENSES1
If the value is the same then show msgbox with the text Values are the same.
If the values are different then msgbox with the text value do not match



Code:
Private Sub CommandButton1_Click()  Sheets("EXPENSES2").Range("D4").Value = Sheets("EXPENSES1").Range("D30").Value
  Sheets("EXPENSES2").Range("F4:K4").Value = Sheets("EXPENSES1").Range("F30:K30").Value
  Sheets("EXPENSES2").Activate
  ActiveSheet.Range("A5").Select
End Sub

Many Thanks
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Code:
Private Sub CommandButton1_Click()  Sheets("EXPENSES2").Range("D4").Value = Sheets("EXPENSES1").Range("D30").Value
  Sheets("EXPENSES2").Range("F4:K4").Value = Sheets("EXPENSES1").Range("F30:K30").Value
  Sheets("EXPENSES2").Activate
  ActiveSheet.Range("A5").Select

'''  *****************  new code below *****************

  if Sheets("EXPENSES2").Range("K32").Value <> Sheets("EXPENSES1").Range("M1").Value then msgbox "No Ma


End Sub
 
Upvote 0
Code:
 Private Sub CommandButton1_Click() Sheets("EXPENSES2").Range("D4").Value = Sheets("EXPENSES1").Range("D30").Value
 Sheets("EXPENSES2").Range("F4:K4").Value = Sheets("EXPENSES1").Range("F30:K30").Value
 Sheets("EXPENSES2").Activate
 ActiveSheet.Range("A5").Select

 ''' ***************** new code below *****************

 if Sheets("EXPENSES2").Range("K32").Value <> Sheets("EXPENSES1").Range("M1").Value then msgbox "No Match"


 End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,816
Members
449,049
Latest member
cybersurfer5000

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