Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete specific part of a cell run-time error 438 3

Status
Not open for further replies.

vba317

Programmer
Mar 5, 2009
708
US
I am trying to delete a specific part of a cell with no luck. The cell is A3 on the sheet I am working on. The full string in cell A3 is JYC Internet                 (351) – includes. What I am trying to do is delete all characters after the - is this possible?

Tom

Code:
strChange = Range("A3").InStr(A3, "-")

 
Range("A3")=Left(Range("A3"),Instr(Range("A3"),"-")

combo
 
I have tried this code but it deletes all characters in the cell. I did have to add another parenthses at the end to avoid a syntax error.

Code:
Range("A3") = Left(Range("A3"), InStr(Range("A3"), "-"))
 
Duane, I tried your idea and nothing gets deleted.
Skip, I tried your idea and it deletes all the info in the cell.
 
Double check the delimiter character in the cell.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
PHV means check the ASCII value of the character actually in the cell.
 
After using the mid statement to isolate the - and using the code statement on my spreadsheet the code is 150.
 
After adding the ascii value into combo's original code it works! Thanks you everyone for your input!


Code:
Range("A3") = Left(Range("A3"), InStr(Range("A3"), Chr(150)))
 
FWIW, Char(150) is what is formally called an n-dash, which is usually printed as being slightly longer than the minus-sign character that is frequently used for a dash.[ ] For comparison, in the next line I will print a minus-sign, an n-dash, then an m-dash.
- [–] [—]
(An experienced eye can usually distinguish them fairly readily.)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top