Parse out field values

rjplante

Active Member
Joined
Oct 31, 2008
Messages
489
I have a cell that has text with a dash in the middle (xxxx-xxxxA). Sometimes there are 4 characters and sometimes there are 5. I would like to take all the text to the right of the dash regardless of the number of characters and place that into another cell. If I use the right(A1,5) formula, it works for one with 5 charachters, but for one with 4 it also takes the dash. What can use formula wise to achieve this?
 

Some videos you may like

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.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
53,083
Office Version
  1. 365
Platform
  1. Windows
How about
=mid(a1,find("-",a1)+1,100)
 

sandy666

Banned - Rules violations
Joined
Oct 24, 2015
Messages
7,499
with Power Query

rawraw.1raw.2
xxxx-xxxxAxxxxxxxxA
xx-xxxxAxxxxxxA
xxxx-xAxxxxxA
xxxx-xxAxxxxxxA
x-xxxxAxxxxxA

Rich (BB code):
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Split = Table.SplitColumn(Source, "raw", Splitter.SplitTextByDelimiter("-", QuoteStyle.Csv), {"raw.1", "raw.2"})
in
    Split

or

rawTAD
xxxx-xxxxAxxxxA
xx-xxxxAxxxxA
xxxx-xAxA
xxxx-xxAxxA
x-xxxxAxxxxA

Rich (BB code):
let
    Source = Excel.CurrentWorkbook(){[Name="Table"]}[Content],
    TAD = Table.AddColumn(Source, "TAD", each Text.AfterDelimiter([raw], "-"), type text)
in
    TAD

or even like this

rawTAD
xxxx-xxxxAxxxxA
xx-xxxxAxxxxA
xxxx-xAxA
xxxx-xxAxxA
x-xxxxAxxxxA

Rich (BB code):
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    TSC = Table.SelectColumns(Table.AddColumn(Source, "TAD", each Text.AfterDelimiter([raw], "-"), type text),{"TAD"})
in
    TSC
 
Last edited:

rjplante

Active Member
Joined
Oct 31, 2008
Messages
489

ADVERTISEMENT

Thank you all for the quick response. Fluff and Rick had the same formula which is what I was looking for and the formula works great. Sandy, Thanks for the VBA as I always like to learn something new and this has given me something to study.
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
53,083
Office Version
  1. 365
Platform
  1. Windows
Glad we could help & thanks for the feedback.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,865
Messages
5,598,530
Members
414,245
Latest member
Major Aly

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
Top