+ Reply to Thread
Results 1 to 3 of 3

Help with VBA code

  1. #1
    Shani
    Guest

    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 )


  2. #2
    Bob Phillips
    Guest

    Re: 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" <[email protected]> wrote in message
    news:[email protected]...
    > 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 )
    >




  3. #3
    Shani
    Guest

    Re: Help with VBA code

    thanks


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1