ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help with VBA code (https://www.excelbanter.com/excel-programming/361076-help-vba-code.html)

Shani

Help with VBA code
 
Column A has values such as http://google.com/news
Column B has values such as http://google.com

I want to write a for loop so that

for i =1 To iLastRow
If Cells( i, 1 ) Like Cells( i, 2 ) Then Cells ( i, 1).Value=
"Whatever"
Next i


This for loop doe snot work. I think the Like is no working correctly.
It works fine when
Cells( i, 1 ) Like "*cat*"

But does not work when comparing with a cell for example If Cells( i, 1
) Like Cells( i, 2 )


Bob Phillips[_14_]

Help with VBA code
 
For i = 1 To iLastRow
If Cells(i, 1).Value Like "*" & Cells(i, 2).Value & "*" Then
Cells(i, 1).Value = "Whatever"
End If
Next i


--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)

"Shani" wrote in message
ups.com...
Column A has values such as http://google.com/news
Column B has values such as http://google.com

I want to write a for loop so that

for i =1 To iLastRow
If Cells( i, 1 ) Like Cells( i, 2 ) Then Cells ( i, 1).Value=
"Whatever"
Next i


This for loop doe snot work. I think the Like is no working correctly.
It works fine when
Cells( i, 1 ) Like "*cat*"

But does not work when comparing with a cell for example If Cells( i, 1
) Like Cells( i, 2 )




Shani

Help with VBA code
 
thanks



All times are GMT +1. The time now is 05:34 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com