+ Reply to Thread
Results 1 to 3 of 3

VBA VLookup in Workbook with Multiple Sheets

Hybrid View

  1. #1
    Registered User
    Join Date
    05-14-2014
    MS-Off Ver
    Excel 2003
    Posts
    7

    VBA VLookup in Workbook with Multiple Sheets

    I am trying write code for a Vlookup based on the current date in d-mmm form. I would like the code to search through each worksheet, there will be a worksheet for each calendar month, and return the value of different categories of disbursements. I am not sure how to do this and went searching on the web for something similar, and tried to adapt it, but I think my coding for the function is not correct, so I get an error.
    I would like the values for each disbursement category and return them to the TestBook2.xlsm workbook under the disbursements tab.

    If anyone could help, I'd really appreciate. I have attached sample spreadsheets and the code below:

    Sub Looking()
    Dim Disb As Workbook
    Dim Wsht As Worksheet
    Dim Search As Date
    Dim FindIt As Integer
    
    
    What = Format(Date, "d-mmm")
    
    For Each Wsht In ActiveWorkbook.Worksheets
    
        With Wsht
        Set Tble_Array = .Range("A2", "A35")
    
            FindIt = WorksheetFunction.VLookup(What, Sheets(.Index).Range("A4:A29"), 6, False)
    End With
    
    If Not IsEmpty(FindIt) Then Exit For
    Next Wsht
    
    Set Tble_Array = Nothing
    VLOOKAllSheets = FindIt
    End Sub
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: VBA VLookup in Workbook with Multiple Sheets

    You can use INDIRECT to make up address based on text so

    INDIRECT("'Sheet1'!$a$1") will give you the A1 cell for Sheet1, you can use these in vlookups to, so with yours

    i'd use MATCH to find the column where the correct category is, and use INDIRECT("'July'!A1:b200") in my lookup.
    Hope this helps

    Sometimes its best to start at the beginning and learn VBA & Excel.

    Please dont ask me to do your work for you, I learnt from Reading books, Recording, F1 and Google and like having all of this knowledge in my head for the next time i wish to do it, or wish to tweak it.
    Available for remote consultancy work PM me

  3. #3
    Registered User
    Join Date
    05-14-2014
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: VBA VLookup in Workbook with Multiple Sheets

    so will i have to change the code each month with this: INDIRECT("'July'!A1:b200") and say "Jan", "Feb", "Mar", etc??
    And I will need all of the categories on a daily basis....

+ 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. [SOLVED] Vlookup from one workbook to another workbook with multipule sheets
    By sally.simpkin in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-30-2013, 06:22 AM
  2. [SOLVED] Macro to copy cells from multiple sheets in workbook to multiple sheets in other workbook
    By KeithMale in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-13-2013, 05:37 PM
  3. [SOLVED] Highlighting the same cell in one workbook with multiple sheets with various sheets names.
    By DanielRay in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-14-2013, 01:50 PM
  4. VLOOKUP across multiple sheets on a different workbook.
    By JamesCBC in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 03-05-2013, 09:38 AM
  5. Replies: 4
    Last Post: 08-17-2006, 01:30 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