Manipulating Text

RAF1112

Board Regular
Joined
Nov 5, 2002
Messages
109
Here is a tough one...

I have the following in a few cells (and others like it) in a cell:

ACC300-245
BD394-231

Can I manipulte the data, using a formula, to get:

ACC-300
BD-394

Any suggestions?

Thanks for your help
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
are the numbers always 3 digits? If not, I can't think of a way to do it without using vba.
 
Upvote 0
Hi,

There is probably a neater way of doing this (especially if Aladin sees this thread :wink: ), but in the meantime try this:

If the text is in A1,
=LEFT(A1,LEN(A1)-7)&"-"&MID(A1,LEN(A1)-6,3)

HTH
 
Upvote 0
here is a quick thought.

there is probably a much more graceful way to do this and this only works if these are the only 2 number types but try this.

put the formula one cell to the right of your data.


=IF(LEN(C8)=10,CONCATENATE(LEFT(C8,3),"-",CONCATENATE(MID(C8,4,3))),CONCATENATE(LEFT(C8,2),"-",CONCATENATE(MID(C8,3,3))))
 
Upvote 0
Not as robust, but just for fun
=LEFT(A1,3-(ISNUMBER(MID(A1,3,1)+0)))&TEXT(MID(A1,FIND("-",A1)-3,3),"-000")

seems to work with your sample data.
 
Upvote 0
FWIW

In VBA

Sub manipulate_data()
[A1].Select
Do While ActiveCell.Value <> 0
ORIGSTRG = ActiveCell.Value
For Y = 1 To Len(ORIGSTRG)
If IsNumeric(Mid(ORIGSTRG, Y, 1)) Then
NewStrg = Left(ORIGSTRG, Y - 1) & "-" & Right(ORIGSTRG, Len(ORIGSTRG) - Y)
ActiveCell.Value = NewStrg
Exit For
End If
Next Y
ActiveCell.Offset(1, 0).Activate
Loop
End Sub
 
Upvote 0

Forum statistics

Threads
1,221,701
Messages
6,161,381
Members
451,700
Latest member
Eccymarge

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