string - Filter out a specific word in Excel Vba -
i want filter out specific words , string. example, "this sample file." word filtered out in excel vba = "file". please help, in dire need of code. thank you.
instr("this sample file.", "file")
give position of first occurrence of "file" in longer string, or 0 if not there.
you can remove elements of string using left
, mid
, right
. len
gives length of string.
putting together:
sub test() dim s1 string dim s2 string dim pos integer s1 = "this sample file." s2 = "file" pos = instr(s1, s2) if pos > 0 debug.print left(s1, pos - 1) & mid(s1, pos + len(s2)) end if end sub
Comments
Post a Comment