InStr has another operand where you can choose
(default) 0 or vbBinaryCompare
1 or vbTextCompare
in your test it would be the third operand but if you started
in a specified position it would be the fourth operand.
Saves one instruction.
This would be a bit faster than insuring that both
are uppercase before comparing. See VBE HELP , also perhaps
http://www.mvps.org/dmcritchie/excel...tm#sensitivity
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages:
http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page:
http://www.mvps.org/dmcritchie/excel/search.htm
"chris" wrote in message ...
This is case Sensitive:
Do this if you dont want it to be
Private Sub Macro1( )
Dim MyStr as String, Val as String
MyStr = "YOURVALUE" '<< All Caps.
For Each c in Selection
Val = UCase( Cstr(c.value))
if InStr(1, Val, MyStr)0 Then c.EntireColumn.Hidden = True
Next
End Sub
----- chris wrote: -----
I don't know how your data is set up so your gonna have to manually select what range you want processed.
i don't recommend you select the entire row if you dont have to, but it will work either way.
create a new macro and put this code in it
Private Sub Macro1( ) '<< this should be provided
Dim MyStr as String
MyStr = "YourValue"
For Each c in Selection
if InStr(1, Cstr(c.value), MyStr)0 Then c.EntireColumn.Hidden = True
Next
End Sub '<< this should be provided
----- Andy Ward wrote: -----
I'm trying to write a Macro that will cycle through each cell in a row (except
the first and last column of the table) and hide the entire column if the cell
doesn't contain a certain word, the word may be on it's own or within a
sentance.
I can't use the sort command as the table contains many merged cells etc
Can any one give me some pointers as to where to start - I have very limited
programming knowledge - have done basic programming but not for a
couple of years or in VBA.
Many Thanks
Andy