Hi,
I want to search a string for certain keywords and if that search returns a false result i.e. the keyword was not found, then a range of cells are copied and pasted to another sheet.
The data i am using is seperated by "/" e.g.
/vehicle/car/Lexus/suspension/.../... etc
The length of these strings can vary.
I have tried to use;
But this will only work when "directory(x)" is not too large and the string is not too small e.g. selecting directory(5) when the string has only 3 words brings up an error.
Is there any way past this?
Im afraid im new to vba and dont know all the commands.
Any help would be greatly appreciated.
Regards,
Crunchie
I want to search a string for certain keywords and if that search returns a false result i.e. the keyword was not found, then a range of cells are copied and pasted to another sheet.
The data i am using is seperated by "/" e.g.
/vehicle/car/Lexus/suspension/.../... etc
The length of these strings can vary.
I have tried to use;
Code:
strInput = Selection.Value
directory = Split(strInput, "/")
If (StrComp(directory(3), "Lexus", vbTextCompare) <> 0) then
Range(ActiveCell.Offset(0, -3), ActiveCell.Offset(0, 4)).Copy _
Destination:=Worksheets("Sheet2").Cells(a, 1)
a = a + 1
Endif
But this will only work when "directory(x)" is not too large and the string is not too small e.g. selecting directory(5) when the string has only 3 words brings up an error.
Is there any way past this?
Im afraid im new to vba and dont know all the commands.
Any help would be greatly appreciated.
Regards,
Crunchie