+ Reply to Thread
Results 1 to 3 of 3

Using Loops

Hybrid View

  1. #1
    Registered User
    Join Date
    06-03-2007
    Posts
    11

    Question Using Loops

    I am trying to work out how to convert the following code using Loops so that after cell K2 the code goes down the column until it reaches a Row where no data exists. Anybody help. I have not used Loops before.

    Thanks


    Sub TravelTime()
    Range("K2:K2").Select
    If Range("G2").Value = "LA" And Range("J2").Value = "San Francisco" Then
    Range("K2").Value = 1
    ElseIf Range("G2").Value = "LA" And Range("J2").Value = "Palm Springs" Then
    Range("K2").Value = 2
    End If
    End Sub

  2. #2
    Registered User
    Join Date
    06-03-2007
    Posts
    11

    Question Using Loops

    I am trying to work out how to convert the following code using Loops so that after cell K2 the code goes down the column until it reaches a Row where no data exists. Anybody help. I have not used Loops before.

    Thanks
    Greg


    Sub TravelTime()
    Range("K2:K2").Select
    If Range("G2").Value = "LA" And Range("J2").Value = "San Francisco" Then
    Range("K2").Value = 1
    ElseIf Range("G2").Value = "LA" And Range("J2").Value = "Palm Springs" Then
    Range("K2").Value = 2
    End If
    End Sub
    Last edited by Greg1234; 06-03-2007 at 07:08 AM.

  3. #3
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Greg1234,

    Please read forum rules below. Duplicate posts are not allowed. I've merged your ost for you. Also all code needs to be wrapped (instructions on link)

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

+ 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