VBA in excel

karlp

Well-known member
UKGSer Subscriber
Joined
Dec 8, 2007
Messages
4,991
Reaction score
1,723
Location
Southampton, England
I am trying to remove characters in a string but having some issues

the part of the string is_dil50

the dil50 could be dil1000 or dil5000 or any other values

If I try using_dil* with the * as a variable it does not work unless I have dil* in the cell

How can I use a variable please

the code is below

'Strip _dil from sample name to open sample workbook

the_string = Sheets("PFAS Data").Range("D1")
the_string = Replace(the_string, "_dil50", "")
Sheets("PFAS Data").Range("D1") = the_string


Openname = ActiveSheet.Range("D1").Text
 
Last edited:
Sounds a bit banal, but you could just do a "find and replace" and replace "dil" with a null field....

Be careful that it doesn't go off and replace words containing those letters in that sequence, but it could be a quick and easy way of doing it maybe.
 


Back
Top Bottom