Reputation: 1
how can i resovlve the follwing issue in VBA
if string contains "SeachText" replace whole string.
ex.
input: "Test_1_The_Text_SeachString_Sth"
input: "Test_2_The_Text_SeachString_Sth"
look for: "SeachrString"
replace with "New_Text"
so after execute the code the
"Test_1_Of_The_Text_SeachString_Sth"
will become "New_Text"
as well as:
"Test_2_Of_The_Text_SeachString_Sth"
will become "New_Text"
Upvotes: 0
Views: 1414
Reputation: 278
Use Instr function like this:
ip1= "Test_1_The_Text_SeachString_Sth"
lookfor="SeachString"
If instr(ip1,lookfor)>0 then
ip1= "newtext"
End if
Upvotes: 2