Macro to cut the last character from a cell?

smreinholtz

New Member
Joined
Jul 10, 2014
Messages
11
I looked around and cannot find a macro to cut the last character from a cell and put it into the next cell over. I would just use the text to column function but there are no common deliminators or text length.

For example:

9000600B
8475A
900655888A
741548C
300B

<tbody>
</tbody>









Becomes:

9000600B
8475A
900655888A
741548C
300B

<tbody>
</tbody>









Thanks in advance for any help!
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Use



Excel 2007
AB
19000600BB
28475AA
3900655888AA
4741548CC
5300BB
Sheet1
Cell Formulas
RangeFormula
B1=RIGHT(A1,1)
B2=RIGHT(A2,1)
B3=RIGHT(A3,1)
B4=RIGHT(A4,1)
B5=RIGHT(A5,1)
 
Upvote 0
Use


Excel 2007
AB
19000600BB
28475AA
3900655888AA
4741548CC
5300BB

<colgroup><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet1

Worksheet Formulas
CellFormula
B1=RIGHT(A1,1)
B2=RIGHT(A2,1)
B3=RIGHT(A3,1)
B4=RIGHT(A4,1)
B5=RIGHT(A5,1)

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>
You need to read the output table the OP posted more carefully... no letters in Column A afterwards.
 
Upvote 0
Perfect thanks!
:confused: What about Column A... you show that with the last character removed... don't you want that anymore?

Assuming you actually meant what you asked for originally, then give this macro a try...
Code:
Sub MoveLastLetterOverOneColumn()
   With Range("A1", Cells(Rows.Count, "A").End(xlUp))
     .Offset(, 1).Value = Evaluate("IF(LEN(" & .Address & "),RIGHT(" & .Address & "),"""")")
     .Value = Evaluate("IF(LEN(" & .Address & "),LEFT(" & .Address & ",LEN(" & .Address & ")-1),"""")")
   End With
 End Sub

HOW TO INSTALL MACROs
------------------------------------
If you are new to macros, they are easy to install and use. To install it, simply press ALT+F11 to go into the VB editor and, once there, click Insert/Module on its menu bar, then copy/paste the above code into the code window that just opened up. That's it.... you are done. To use the macro, go back to the worksheet with your data on it and press ALT+F8, select the macro name (MoveLastLetterOverOneColumn) from the list that appears and click the Run button. The macro will execute and perform the action(s) you asked for. If you will need to do this again in this same workbook, and if you are using XL2007 or above, make sure you save your file as an "Excel Macro-Enabled Workbook (*.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.
 
Upvote 0
:confused: What about Column A... you show that with the last character removed... don't you want that anymore?

Assuming you actually meant what you asked for originally, then give this macro a try...
Code:
Sub MoveLastLetterOverOneColumn()
   With Range("A1", Cells(Rows.Count, "A").End(xlUp))
     .Offset(, 1).Value = Evaluate("IF(LEN(" & .Address & "),RIGHT(" & .Address & "),"""")")
     .Value = Evaluate("IF(LEN(" & .Address & "),LEFT(" & .Address & ",LEN(" & .Address & ")-1),"""")")
   End With
 End Sub

This macro works perfectly. Thank you for the help!
 
Upvote 0

Forum statistics

Threads
1,215,381
Messages
6,124,614
Members
449,175
Latest member
Anniewonder

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