Left

ExcelRoy

Well-known Member
Joined
Oct 2, 2006
Messages
2,540
Office Version
  1. 365
Platform
  1. Windows
Hi,

How could I remove the first 2 characters to a cell

I was thinking LEFT but not sure

Thanks
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Hi63falcondude,

=IF(ISNUMBER(A1),A1,RIGHT(A1,LEN(A1)-2))

works like a dream, great once again

many thanks
 
Upvote 0
Hi 63falcondude,

Can I have IFERROR as part of this formula?

Regards
 
Upvote 0
ExcelRoy,

Here is a macro solution for you to consider as long as the numbers/strings are at least 3 characters long.

Sample raw data in the active worksheet:


Excel 2007
A
1ADELANTE
263falcondude
3AkaTrouble
4hiker95
5ExcelRoy
6Aladin
7MrExcel
8A1:A7
9abc
10123
11
Sheet1


And, after the macro:


Excel 2007
A
1ELANTE
2falcondude
3aTrouble
4ker95
5celRoy
6adin
7Excel
8:A7
9c
103
11
Sheet1


Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).

1. Copy the below code
2. Open your NEW workbook
3. Press the keys ALT + F11 to open the Visual Basic Editor
4. Press the keys ALT + I to activate the Insert menu
5. Press M to insert a Standard Module
6. Where the cursor is flashing, paste the code
7. Press the keys ALT + Q to exit the Editor, and return to Excel
8. To run the macro from Excel press ALT + F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.

Code:
Sub RemoveFirstTwoCharacters()
' hiker95, 02/24/2017, ME993056
Dim ADDR As String
With ActiveSheet
  ADDR = .Range("A1", Cells(Rows.Count, "A").End(xlUp)).Address(0, 0)
  .Range(ADDR) = Evaluate(Replace("IF(Len(@)>2,MID(@,3,LEN(@)-2))", "@", ADDR))
End With
End Sub

Before you use the macro with Excel 2007 or newer, save your workbook, Save As, a macro enabled workbook with the file extension .xlsm, and, answer the "do you want to enable macros" question as "yes" or "OK" (depending on the button label for your version of Excel) the next time you open your workbook.


Then run the RemoveFirstTwoCharacters macro.
 
Upvote 0

Forum statistics

Threads
1,215,110
Messages
6,123,146
Members
449,098
Latest member
Doanvanhieu

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