+ Reply to Thread
Results 1 to 6 of 6

Getting error while doing Vlookup for a TableArray that refers to a Variable

  1. #1
    Registered User
    Join Date
    10-03-2020
    Location
    London
    MS-Off Ver
    2016
    Posts
    3

    Getting error while doing Vlookup for a TableArray that refers to a Variable

    Hi,

    I have some problem with VBA coding when i want to make a Vlookup and the TableArray always starts from Column "A" to "K", but the rows can differ depending on the situation.

    For example
    Range("P1").Value = Range("O2").Value & Range("M2").Value
    Range("P2").Value = Range("O3").Value & Range("M3").Value

    I have written "A" in cell "O2" and "K" in cell "O3". M2 and M3 is a row number I will get from a formula. So lets say M2=10 and M3=20, this means my "P1" will be A10 and "P2" will be K20. So the table array i want in Vlookup is A10:K20. But somehow the code is wrong, when i use "ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-8], Indirect(P1): Indirect(P2), 10, FALSE)"

    I have tried many and different solution, but it didnt work out. This is my latest, but failed solution. I attach a file since maybe my explanation is not that good. It is supposed to do Vlookup under any column under "Last week" and to get the "current week" comments.

    Cross forum: In Mr.excel

    The whole code is here:

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by Endered5; 10-03-2020 at 10:43 AM.

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,481

    Re: Getting error while doing Vlookup for a TableArray that refers to a Variable

    Can you show in your sample workbook what is supposed to be happening without using code?

  3. #3
    Registered User
    Join Date
    10-03-2020
    Location
    London
    MS-Off Ver
    2016
    Posts
    3

    Re: Getting error while doing Vlookup for a TableArray that refers to a Variable

    Here is the example. I have "8 tables"(see Column A) repeating from A-D(see header of the "table" in green). So I put Vlookup formula in this case from table 5-8 in the column "last week". Table 1-4 is first cycle, while Table 5-8 is second cycle.

    I put Vlookup at table 5, column "Last week", and looking for the value at Column B and here I want the table array to be "Table 1", and i want the value at Column K which is the "Current week comment".

    So when i Fill the "last week" Vlookup in Table5(header A), i want the table array to be table1(header A). When I fill the Table 6(header B), i want it to be 2(header B). Table 7(header C) vs table 3(header C). Table 8(D) vs table 4(D).
    Attached Files Attached Files

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,884

    Re: Getting error while doing Vlookup for a TableArray that refers to a Variable

    crossposted: https://www.mrexcel.com/board/thread...-cell.1147412/

    Rule 03: Cross-posting Without Telling Us

    Your post does not comply with Rule 3 of our Forum RULES. Do not cross-post your question on multiple forums without telling us about your threads on other forums.

    Post a link to any other forums where you have asked the same question.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Read this to understand why we ask you to do this.

    I have added the crosspost reference for you today. Please comply with this and all our rules in the future
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  5. #5
    Registered User
    Join Date
    10-03-2020
    Location
    London
    MS-Off Ver
    2016
    Posts
    3

    Re: Getting error while doing Vlookup for a TableArray that refers to a Variable

    I just noticed that it isnt allowed. I just updated my post as well with cross forum.

    Thanks for the heads up

  6. #6
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,884

    Re: Getting error while doing Vlookup for a TableArray that refers to a Variable

    It is not adequate to just post the site, you need to actually provide the link to the post so that others can look at what has been already provided. Notice that in post #4, I provided the actual link. Additionally, it is important that you read the link provided in the thread so that you have a better understanding as to why we ask for this. I will post it here again.

    https://www.excelguru.ca/content.php?184

+ 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. Replies: 7
    Last Post: 05-19-2016, 05:12 AM
  2. [SOLVED] Passing variable in VLookup string in VBA Code- I get an error
    By rv02 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-07-2016, 04:37 PM
  3. Vlookup Different workbook Cell refers to sheet
    By RandomPezzer in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-12-2015, 05:42 PM
  4. [SOLVED] New Error/Old Code - Run Time Error 91; Object variable or With block variable not set
    By humboldtguy in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-15-2014, 12:39 AM
  5. Forumla which refers to a cell which refers to a sheet name
    By awiller2 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 12-03-2012, 09:57 PM
  6. Vlookup UDF with concatenated lookUpVal in tableArray
    By wotadude in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-22-2008, 12:32 AM
  7. [SOLVED] vlookup- refers to the range within the external file
    By Mike McLellan in forum Excel General
    Replies: 6
    Last Post: 04-28-2006, 04:35 PM

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