View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.misc
JLatham JLatham is offline
external usenet poster
 
Posts: 2,203
Default Search for string containing

For you exact statement, I think you could rewrite it this way:

If Instr(.Cells(X, "K"),"RG") 0 Then
.Cells(X,"Q").Value = "TRC"
End If

"richzip" wrote:

Hello,

I have the following in VBA:

If .Cells(X, "K") = "RG" Then
.Cells(X, "Q").Value = "TRC"

How can I modify this formula to look in column K for a string that contains
RG and perform the same function? (i.e., if it contains RG-TRVL or TRVL-RG,
then TRC should automatically be placed in column Q)?

Thank you.