Consulting

Results 1 to 5 of 5

Thread: Solved: Vlookup loop

  1. #1

    Solved: Vlookup loop

    I would like some help on a vlookup loop please.

    I can hard code the formula into a cell and drag it
    (=VLOOKUP(Full!H1,Jobs!A1:B5000,2,FALSE))

    , however, I want a codeless page and would rather it be in vba code.

    I have attached a sample and the code is in the full page and column "I".

    could some please assist in the code to make it a loop to all rows with data in.

    Regards

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Public Sub ProcessData()
    Const TEST_COLUMN As String = "A" '

  3. #3

    sorry I dont understand

    XLD

    sorry, but I dont understand the answer?

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Sorry, I have a problem in posting sometimes.

    [vba]

    Public Sub ProcessData()
    Const TEST_COLUMN As String = &quot;A&quot; '<=== change to suit
    Dim i As Long
    Dim iLastRow As Long
    Dim cell As Range
    Dim sh As Worksheet

    With ActiveSheet

    iLastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
    For i = 1 To iLastRow
    If .Cells(i, &quot;H&quot = &quot;&quot; Then
    .Cells(i, &quot;I&quot.Value = &quot;&quot;
    Else
    .Cells(i, &quot;I&quot.Value = Application.VLookup(.Cells(i, &quot;H&quot.Value, Range(&quot;'Jobs'!A1:B5000&quot, 2, False)
    End If
    Next i

    End With

    End Sub
    [/vba]

  5. #5
    XLD.
    you are a god...

    Thank you

Posting Permissions

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