EzGoingKev
Registered User.
- Local time
- Yesterday, 20:26
- Joined
- Nov 8, 2019
- Messages
- 188
Good morning.
I have text in a table like this:
Some data has the make and " - " and then extra info. Some has the extra info in parentheses. Some does not have any extra info that needs to be removed.
I need it like this:
I googled this and tried using Array but received errors. I wrote this code here:
It runs without errors but gives me this as result:
It is only doing the text2 from the code but not the text1.
Would someone please advise on what I need to change to get this to work?
I have text in a table like this:
Make |
---|
ALFA ROMEO |
FREIGHTLINER - TRUCKS - MEDIUM / HEAVY DUTY |
HINO (MEDIUM DUTY) |
MERCEDES-BENZ |
NISSAN |
I need it like this:
Make |
---|
ALFA ROMEO |
FREIGHTLINER |
HINO |
MERCEDES-BENZ |
NISSAN |
Code:
Public Function GetMakeName(strIn As Variant)
strIn = strIn & ""
On Error GoTo ErrorHandler
Dim text(1 To 2) As String
text(1) = " - "
text(2) = " ("
Dim item As Variant
For Each item In text
GetMakeName = Split(strIn, item)(0)
Next item
Error_Exit:
Exit Function
ErrorHandler:
MsgBox Error$
Resume Error_Exit
End Function
It runs without errors but gives me this as result:
Expr1 |
---|
ALFA ROMEO |
FREIGHTLINER - TRUCKS - MEDIUM / HEAVY DUTY |
HINO |
MERCEDES-BENZ |
NISSAN |
Would someone please advise on what I need to change to get this to work?
Last edited: