Parse out field values

rjplante

Well-known Member
Joined
Oct 31, 2008
Messages
566
Office Version
  1. 365
Platform
  1. Windows
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?
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
How about
=mid(a1,find("-",a1)+1,100)
 
Upvote 0
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:
Upvote 0
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.
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,585
Messages
6,120,391
Members
448,957
Latest member
Hat4Life

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