Can I use a left or right command but exclude a vairable?

TWTHOMAS

Board Regular
Joined
Mar 26, 2010
Messages
103
Office Version
  1. 2016
Platform
  1. Windows
I have a list of SSN's that I use to match up to a list of employees in a travel system. Unfortunatley the travel system allows individual users to have two accounts.

One acccount is thier SSN and the other is their SSN with a G at the end.

I would like do something like a =right(A2,4) but I want to ignore any of the G's and get nex to last rightmost 4 on ones that have the G.

The easy way I have found is to do a replace G with backspace but I
really want to completely automate the process.

I don't know much about macros or VBA so I hope someone has a formula variable I can use.

Let's say my list is

123546565
839484736G
837362577G
984838827
762552561
726355262G

I want to get

6565
4736
2577
8827
2561
7262

Thanks in advance.

If I have inadvertantly created a real SSN my appologies.
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
If it's only a G that could be at the end...

Try

=RIGHT(SUBSTITUTE(A1,"G",""),4)
 
Upvote 0

Forum statistics

Threads
1,224,316
Messages
6,177,849
Members
452,810
Latest member
jeffrey0409

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