Results 1 to 4 of 4

automate Vlookup and Autofilter

Threaded View

  1. #1
    Registered User
    Join Date
    06-13-2010
    Location
    New Brunswick, New Jersey
    MS-Off Ver
    Excel 2007
    Posts
    2

    automate Vlookup and Autofilter

    Hello - I am well versed with formulas but still a begginer with VBA so bear with me.

    I am trying to write a Macro that performs a Vlookup using a value in Sheet1 against an array in Sheet 2.
    There are three columns in sheet 1 - ProductCode, CodeFamily, CurrentInventory
    I want the value of the function to drop the new inventory number (off the array in Sheet 2) in new Column D
    Then after it returns that value I want in to autmatcally filter the differences between CurrentInventory (column C) and UpdatedInventory (column D)

    Here is where I got so far - I am stuck on the Loop function and haven't performed an autofilter yet...
    Sub Vlookup()
    Dim lookFor As Range
    Dim rng As Range
    Dim found As Variant
    Worksheets("Sheet1").Activate
     
    Set lookFor = Sheets("Sheet1").Range("A2")
    Set rng = Sheets("Sheet2").Columns("A:B")
    ActiveCell.Offset(0, 0).Select
    Do While Not IsEmpty(ActiveCell.Select)
    On Error Resume Next
    found = Application.VLookup(lookFor.Value, rng, 2, 0)
    Sheets("sheet1").Range("d2").Active
    ActiveCell.Value = found
    Loop
    On Error GoTo 0
    End Sub
    Last edited by royUK; 06-13-2010 at 09:43 AM. Reason: add code tags,edit title

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