+ Reply to Thread
Results 1 to 2 of 2

vlookup over multiple pages using vba

Hybrid View

  1. #1
    Registered User
    Join Date
    07-14-2014
    Location
    Edmonton, AB
    MS-Off Ver
    2013
    Posts
    2

    vlookup over multiple pages using vba

    Im trying to write vlookup code using VBA that will cycle through four different worksheets. If the vlookup doesn't match or produce a result, I want a blank. This is the code I have so far. It only looks up the first sheet andenters N/A directly into the cells. I need to fix this before I can cycle through the other sheets.

    Sub Button1_Click()

    Range("Master_Input_Range").Clear

    Dim rngLookupValue As Range
    Dim rngBranchCableScheduleCableTagRange As Range
    Dim rngEHTCableScheduleCableTagRange As Range
    Dim rngHVACCableScheduleCableTagRange As Range
    Dim rngPICCableScheduleCableTagRange As Range
    Dim rngPartial As Range
    Dim varResult As Variant


    Set rngLookupValue = Sheets("Master").Range("Master_Tag")
    Set rngPartial = Sheets("Master").Range("Master_Partial")
    Set rngPICCableScheduleCableTagRange = Sheets("PIC Cable Schedule").Range("PIC_Cable_Schedule_Cable_Tag_Range")
    Set rngHVACCableScheduleCableTagRange = Sheets("HVAC Cable Schedule").Range("HVAC_Cable_Schedule_Cable_Tag_Range")
    Set rngEHTCableScheduleCableTagRange = Sheets("EHT Cable Schedule").Range("EHT_Cable_Schedule_Cable_Tag_Range")
    Set rngBranchCableScheduleCableTagRange = Sheets("Branch Cable Schedule").Range("Branch_Cable_Schedule_Cable_Tag_Range")


    varResult = Application.WorksheetFunction.VLookup(rngLookupValue, rngPICCableScheduleCableTagRange, 6, 0)
    If Not IsError(varResult) Then rngPartial = varResult

    End Sub

  2. #2
    Registered User
    Join Date
    07-14-2014
    Location
    Edmonton, AB
    MS-Off Ver
    2013
    Posts
    2

    Re: vlookup over multiple pages using vba

    forget it. Got it

    varResult = Application.WorksheetFunction.IfError(Application.WorksheetFunction.VLookup(rngLookupValue, rngPICCableScheduleCableTagRange, 5, False), Application.WorksheetFunction.IfError(App lication.WorksheetFunction.VLookup(rngLookupValue, rngHVACCableScheduleCableTagRange, 7, False), Application.WorksheetFunction.IfError(Application.WorksheetFunction.VLookup(rngLookupValue, r ngEHTCableScheduleCableTagRange, 6, False), Application.WorksheetFunction.IfError(Application.WorksheetFunction.VLookup(rngLookupValue, rngBranchCableScheduleCableTagRange, 5, False), ""))))
    If Not IsError(varResult) Then rngPartial = varResult

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Help getting multiple results from multiple criteria on multiple pages
    By ERaasio in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 07-03-2013, 07:29 PM
  2. vlookup from multiple pages
    By 00Able in forum Excel General
    Replies: 2
    Last Post: 02-04-2012, 10:54 PM
  3. Combining Vlookup and sum across pages
    By ORC in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-01-2011, 08:49 AM
  4. Linking multiple excel files with multiple pages
    By halo1234 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-29-2008, 06:42 AM
  5. VLOOKUP with multiple pages
    By Zirus in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-13-2007, 08:29 AM

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