Macro to cut first 20 characters and paste, delete characteres 21 to 23 and delete last 4 characters and keep the rest

PRVANWYK

New Member
Joined
Apr 26, 2011
Messages
4
Good day all,
I'm in a desperate need for macro to solve the following:
MP200-000-60-200-000 - HOPPER AERATION AIR MANIFOLD UNIT 1-6.iam

I need the first 20 characters to be cut and pasted in another cell, then the "space-dash-space" to be deleted, the title part must be kept and the .iam must be deleted.
I have about 25000 entries acros various spreadsheets.
I used to have a macro to delete the last 4 characters from the cell.
But now I need a bit more.
All the data is in Column A. I know I can use the MID function to a certain degree but I can't have a linked cell in my results as I need to use it again in another application that will pick up the formula.

Please help.
Thank you
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
For instance:

Code:
Sub f()
    For Each r In Columns(1).SpecialCells(2, 2)
        r.Offset(, 1) = Split(r, " - ")(0)
        r.Value = Left(Split(r, " - ")(1), Len(Split(r, " - ")(1)) - 4)
    Next
End Sub

or:

Code:
Sub f()
    For Each r In Columns(1).SpecialCells(2, 2)
        sq = Split(r, " - ")
        r.Offset(, 1) = sq(0)
        r.Value = Left(sq(1), Len(sq(1)) - 4)
    Next
End Sub
 
Upvote 0
Can you use this?
Excel Workbook
ABC
1MP200-000-60-200-000 - HOPPER AERATION AIR MANIFOLD UNIT 1-6.iamMP200-000-60-200-000HOPPER AERATION AIR MANIFOLD UNIT 1-6
Sheet1
Excel 2007
Cell Formulas
RangeFormula
B1=LEFT(A1,20)
C1=MID(A1,LEN(B1)+4,(LEN(MID(A1,LEN(B1)+4,256))-4))
 
Upvote 0
Hi Jim,
I need to move data without the formulas to another application, but thank you.
I do appreciate the reply.
regards
 
Upvote 0
You can of course copy both columns B & C and paste them AS VALUES, in place or to Columns D & E. Oh well... FWIW
 
Upvote 0

Forum statistics

Threads
1,224,522
Messages
6,179,292
Members
452,902
Latest member
Knuddeluff

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