How can I separate cell contents at a character?

JOSHSKORN

New Member
Joined
Aug 22, 2022
Messages
15
Office Version
  1. 2019
Platform
  1. Windows
I have a song list that I copied and pasted from a website that looks like this:
Song Title - Artist
So, there's a dash that separates the two. Lets say I have this in Cell A2 (headings in row 1) and in Cells B2 and C2, I want "Song Title" and "Artists", respectively. How can I achieve this?

I would be comfortable using VBA if I have to.

I know I'd have to find the position of the Dash, read before, then after it, then trim the space before and after the dash. I'm just not sure how to do that.
 

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.
You could use:
Excel Formula:
=TRIM(LEFT(A2,FIND("-",A2)-1))
in B2 and
Excel Formula:
=TRIM(MID(A2,FIND("-",A2)+1,LEN(A2)))
in C2
 
Upvote 0
You could use:
Excel Formula:
=TRIM(LEFT(A2,FIND("-",A2)-1))
in B2 and
Excel Formula:
=TRIM(MID(A2,FIND("-",A2)+1,LEN(A2)))
in C2
Both of these return #Value in B2/C2. In A2, I have: (Don’t Fear) The Reaper – Blue Oyster Cult

Then I noticed the longer dash in A2 than what's in the formulas provided, I tried swapping the short for the longer dash, no luck.
 
Upvote 0
You said you tried this but just in case there was a typo try what I have here in B & C.
If that doesn't work tell us what the formulas in Columns D & E return (these will only work on that exact phrase though since they are looking for Blue.

Book3
ABCDE
1DescriptionPart 1Part 2ASCIIUnicode
2(Don’t Fear) The Reaper – Blue Oyster Cult(Don’t Fear) The ReaperBlue Oyster Cult1508211
Sheet1
Cell Formulas
RangeFormula
B2B2=TRIM(LEFT(A2,FIND("–",A2)-1))
C2C2=TRIM(MID(A2,FIND("–",A2)+1,LEN(A2)))
D2D2=CODE(MID(A2,FIND(" Blue",A2)-1,1))
E2E2=UNICODE(MID(A2,FIND(" Blue",A2)-1,1))
 
Upvote 0
The hyphen in the formula provided by @RoryA is CHAR(45) whereas the OP's is CHAR(208). Try replacing that in the formula and see if that works.
Excel Formula:
=TRIM(LEFT(A2,FIND(CHAR(208),A2)-1))

Excel Formula:
=TRIM(MID(A2,FIND(CHAR(208),A2)+1,LEN(A2)))
 
Upvote 0
Hi @Cubist, that seems unlikely
My XL2BB shows how I arrived at the code for it after copying in the text provided.

PS: ascii 150 is En-Dash which is a fairly well known dash in publishing and En is a useful word when playing scrabble ;)
 
Upvote 0
@Alex Blakenburg I copied your XL2BB and got a different result. I learned from another post the first 128 characters of CODE() and UNICODE() use the same encoding, but the rest of the ASCII character set uses a different encoding. UNICODE is prevalent these days.
Book2
ABCDE
1DescriptionPart 1Part 2ASCIIUnicode
2(Don’t Fear) The Reaper – Blue Oyster Cult(Don’t Fear) The ReaperBlue Oyster Cult2088211
Sheet10
Cell Formulas
RangeFormula
B2B2=TRIM(LEFT(A2,FIND("–",A2)-1))
C2C2=TRIM(MID(A2,FIND("–",A2)+1,LEN(A2)))
D2D2=CODE(MID(A2,FIND(" Blue",A2)-1,1))
E2E2=UNICODE(MID(A2,FIND(" Blue",A2)-1,1))
 
Upvote 0
I knew I left the Unicode there for a reason ;).
We agree on the Unicode, and 208 seems to be vary based on the character set you are using so I would go with the Unicode version. Mind you just copying in the dash seems to have worked on both your and my machine.
(What language / character set are you using ?)
 
Upvote 0
I pasted in only the dash and the same result for me. I'm using US-ASCII.
Book2
ABCDE
1DescriptionPart 1Part 2ASCIIUnicode
22088211
Sheet10
Cell Formulas
RangeFormula
D2D2=CODE(A2)
E2E2=UNICODE(A2)
 
Upvote 0

Forum statistics

Threads
1,216,124
Messages
6,128,990
Members
449,480
Latest member
yesitisasport

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