Excel VBA Left function for 2 different cells

NLU_VBA

New Member
Joined
Jun 25, 2024
Messages
14
Office Version
  1. 365
Platform
  1. Windows
Hello,

In an Excel sheet I want to compare the 4 first digits in 2 different cells C5 and C9, and make sure that these 4 digits are identical in both cells. Otherwise a message "Please review your text" must be displayed.
I guess that the LEFT function must be used.

As I am a beginner in VBA, can someone help me please?
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
How are these values entered into cells C5 and C9?
Is it done manually?

When do you want this comparison to run?
As data is being manually entered in cells C5 and C9?
Or do you want this comparison to be run at some other time/event?
 
Upvote 0
How are these values entered into cells C5 and C9?
Is it done manually?

When do you want this comparison to run?
As data is being manually entered in cells C5 and C9?
Or do you want this comparison to be run at some other time/event?
In C5 values are entered manually; in C9 there is a dropdown menu, but the 4 first digits in all options have the same format as those that need to be entered in cell C5
 
Upvote 0
So, are you all set now, with the code that dreid1011 provided?
Note that you have to run that code manually.

If you want it to run automatically when entries are made to cells C5 and C9, that can be done.
 
Upvote 0
So, are you all set now, with the code that dreid1011 provided?
Note that you have to run that code manually.

If you want it to run automatically when entries are made to cells C5 and C9, that can be done.
Yes, I am! It works well!
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

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