Is there any way to delete everything after a certain character or word?
EXAMPLE: "example– 3:47"
Is there any way to delete everything after the "–" in every cell or a specified group of cells?
Thanks in advance
-Tom
find -* replace with nothing
Mojito connoisseur and a dabbler in Cisco
where does code go ?
look here
how to insert code
how to enter array formula
why use -- in sumproduct
recommended reading
wiki Mojito
how to say no convincingly
most important thing you need
Martin Wilson: SPV
and RSMBC
Hello Tom,
welcome to the forum. You can use the LEFT and FIND functions in a combination in another cell. For your example above:
=LEFT(A1,FIND(CHAR(150),A1))
The dash in your example is the character 0150, for a simple dash as found on the keyboard, use
=LEFT(A1,FIND("-",A1))
Copy the formula down the column of your data. You can copy the result and use Paste Special - Values to copy only the values elsewhere.
teylyn
Microsoft MVP - Excel
At Excelforum, you can say "Thank you!" by clicking theicon below the post.
Avoid pie charts with more than two data points. Why? See here (pdf, 559 kb). The only acceptable pie chart is here.
You can have a formula in another cell that does that truncation
=LEFT(A1,FIND("-",A1))
If you want to do it in place, then you need some VBA.
This code is written to go in the sheet with the data. If you want a more general solution use this, which can go in a Module:Code:' Find all occurrences of char in worksheet and truncate any characters following it Public Sub TruncAfter(char As String) Dim c As Range Dim pos As Long For Each c In UsedRange pos = InStr(c.Value, char) If pos > 0 Then c.Value = Mid(c.Value, 1, pos) End If Next c End Sub
Code:' Find all occurrences of char in worksheet and truncate any characters following it Public Sub TruncAfter(ws as Worksheet, char As String) Dim c As Range Dim pos As Long For Each c In ws.UsedRange pos = InStr(c.Value, char) If pos > 0 Then c.Value = Mid(c.Value, 1, pos) End If Next c End Sub
Making the world a better place one fret at a time
||||||
If someone helped you, please click on the star icon at the bottom of their post
If your problem is solved, please update the first post:
EDIT, Go Advanced button, set Prefix to SOLVED
[code]
' Enclose code in tags like this
[/code]
Don't attach a screenshot--just attach your Excel file! It's easier and will let us experiment with your data, formulas, and code.
Last edited by 6StringJazzer; 03-18-2010 at 09:23 PM.
Making the world a better place one fret at a time
||||||
If someone helped you, please click on the star icon at the bottom of their post
If your problem is solved, please update the first post:
EDIT, Go Advanced button, set Prefix to SOLVED
[code]
' Enclose code in tags like this
[/code]
Don't attach a screenshot--just attach your Excel file! It's easier and will let us experiment with your data, formulas, and code.
edit ah i was just going to say that lol but if it is char 150 then find
hold down alt and key 0150 on the numeric keypad then put * will do it
Last edited by martindwilson; 03-18-2010 at 09:25 PM.
Mojito connoisseur and a dabbler in Cisco
where does code go ?
look here
how to insert code
how to enter array formula
why use -- in sumproduct
recommended reading
wiki Mojito
how to say no convincingly
most important thing you need
Martin Wilson: SPV
and RSMBC
THANK YOU SO MUCH!
the one that is easiest that i used was the tip on replacing "–*" with nothing. This will save me so much time. Thank you again
-Tom
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks