Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course

vlookupworkbook

0

Hello,

Your tutorial was great. I was able to get the formula to work.  The issue I am having right now is that when I change the data in the sheets, it will not populate the new data in the summary page. I have included the formula I am using to get this to work.  I need the updated data to autopopulate once a change has been made.

=vlookupworkbook(A2,A3:H120,8,0,"master listing")

Thank you,

Answer
Discuss

Answers

0
Selected Answer

Hello Alicia and welcome to the forum,

First, it is not recommended to include an email address in a post, so you may want to edit your post and remove it.

I would suggest you look at John_Ru's answer to a similar post (Sept '22) on the same issue. Here is the link:
VLOOKUPWORKBOOK

Cheers   :-)

Discuss

Discussion

I did look at this post.  But I am unsure where to place John Ru's suggestion.  I was able to do this action since you had it all layed out for me.  Where/how do I make the updates so that the data updates?
Alicia (rep: 2) Nov 28, '23 at 3:43 pm
Alicia. I'm confused now!

It looks like you removed any email address from your question (as Willie correctly suggested) but what do you mean by "I was able to do this action since you had it all laid out for me" and what bit of my earlier Answer did you not follow? 
John_Ru (rep: 6142) Nov 28, '23 at 6:26 pm
I copied what John Ru had in his discusion but it did not work. Is this what I was suppose to do.I am unsure where/how to use =wbProduct(6).  I am a beginner at this and really trying to learn.

"Laid out for me"  all I had to do was copy the code to add to the macro module.  With the new information from John Ru, I do not know where to place this or do other coding need to be deleted.
Alicia (rep: 2) Nov 29, '23 at 7:31 am
Alicia

You don't need to use wbProduct in your spreadsheet- that was just a simple User Defined Function (UDF) I created to demonstrate how UDFs could update automatically.

It would help if you uploaded your file (if possible). Please edit your original question and use the Add Files... button to upload a representative Excel file (without any personal data) to show your existing data (and macros).- I'll then provide an Answer including the corrected file.
John_Ru (rep: 6142) Nov 29, '23 at 9:05 am
Okay, I've now added a full Answer and sample file
John_Ru (rep: 6142) Nov 29, '23 at 12:56 pm
Add to Discussion
0

 Alicia,

You didn't attach an Excel file to your question so I've created one (attached below), based on the code provided by the user for my previous Answer New VLOOKUPWORKBOOK.

As that file leaves me, Sheet1 (green) cell J2 has your (UDF) formula:

=vlookupworkbook(A2,A3:H120, 8,0, "master listing")

where the bold bit means the third sheet is ignored.

It looks up the values from (yellow) cell A2 (value 55) but returns 0 (since it isn't on any searched sheet).

Now go to Sheet2 and see (blue) cell A7 is 58 and the 8th column (H7) is 240.

If you change A7 to 55 then go back to Sheet1, you'll see green J2 now shows that 240. Change Sheet2 H7 to 350 say and J2 will be updated to 350.

The UDF result is now "volatile" (and isupdated automatically, if autocalculation is set).

This is done by the addition of the line in bold below within Module1 code:

Function VLOOKUPWORKBOOK( _
    lookup_value As Variant, _
    table_array As Range, _
    col_index_num As Integer, _
    Optional range_lookup As Boolean, _
    Optional sheets_to_exclude_1 As String, _
    Optional sheets_to_exclude_2 As String, _
    Optional sheets_to_exclude_3 As String, _
    Optional sheets_to_exclude_4 As String, _
    Optional sheets_to_exclude_5 As String)

Application.Volatile True

Dim mySheet As Worksheet
Dim value_to_return
Dim sheets_to_exclude

 On Error Resume Next

 'Put sheets to exclude into an array
sheets_to_exclude = Array(sheets_to_exclude_1, sheets_to_exclude_2, sheets_to_exclude_3, sheets_to_exclude_4, sheets_to_exclude_5)

 'Cycle through all sheets in the workbook
For Each mySheet In ActiveWorkbook.Worksheets

     'Check if the sheet needs to be excluded or not.
    If Not (UBound(Filter(sheets_to_exclude, mySheet.Name)) > -1) Then

         With mySheet
             Set table_array = .Range(table_array.Address)
             'Run the actual vlookup function on the current sheet that is being looped though.
            value_to_return = WorksheetFunction.VLookup(lookup_value, table_array, col_index_num, range_lookup)
         End With
         'Exit the loop once have a value to return.
        If Not IsEmpty(value_to_return) Then
            Exit For
        End If
     End If
 Next mySheet

 'Send the result back to the cell that contains the function.
VLOOKUPWORKBOOK = value_to_return

End Function

Hope this makes sense and solves your problem. if so, please remember to mark this Answer as Selected (you may have to Deselect Willie's Answer which pointed to my earlier Answer, as referenced above).

Discuss
0

Thanks for answering, I appreciate you. You made my day. 

Discuss

Discussion

Hope that worked for you, Lizzie. If so, I'm not clear why you selected Willie's Answer instead, given you said you didn't know what do do with the code from my previous Answer (which Willie pointed you to).

For the future, please note that Answers should be reserved for solutions but replies (like yours above) can be made on the Discussion below an Answer
John_Ru (rep: 6142) Dec 11, '23 at 3:47 am
Add to Discussion


Answer the Question

You must create an account to use the forum. Create an Account or Login