+ Reply to Thread
Results 1 to 4 of 4

Need your knowledge - vlookup with dynamic sheet reference VBA

  1. #1
    Registered User
    Join Date
    03-16-2018
    Location
    London
    MS-Off Ver
    Office Excel 2013
    Posts
    4

    Need your knowledge - vlookup with dynamic sheet reference VBA

    Hi there !

    I come here and request your knowledge :

    I'm beginner with VBA, I wrote a code and here is the main part where i'm blocked :

    Please Login or Register  to view this content.
    [/U][/B]

    The part where i'm blocked is the last part, the vlookup formula.
    What i want my code to do is quite simple :
    it create each time 5 tab one called Ledger and the others with the name of our member's team, and add a variable (which is here today's date, each time you run the code).
    It copy and paste data from another sheet, and then copy and paste those data to each member sheet, using the clerk number as a filter for each member ( in my code, i've only wrote the code for member no 3)
    This code is supposed to be run regularly, with 5 sheet created each time (in the same order), and i would like to bring comments from the previous run to the new tab using vlookup, for each tab.
    I looked for many clues on the internet, but could only find Activesheet.Previous.Name (in red), but it works only on the previous worksheet. I need a vlookup based on the emplacement of the tab/sheet but minus 5 - the 5th previous sheet ( am i clear ? :x), and this for each sheet.

    Maybe this screen below could be more explicit for you:
    Exemple.PNG

    I tried Count and Index, but it doesn't work. But also i'm not sure to know how to insert them in the vlookup formula...
    What should i replace ActiveSheet.Previous.Name with ?

    Any clues ?

    Thanks for your help and sorry if i'm not very clear
    Kenken1987
    Last edited by kenken1987; 03-16-2018 at 07:30 PM.

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: Need your knowledge - vlookup with dynamic sheet reference VBA

    One way
    Add a function to find the latest worksheets that matches to the sheets to be added.
    e.g
    1) change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    2) Add function
    Please Login or Register  to view this content.
    Each similar sheet will be added right after the previous sheet...

  3. #3
    Registered User
    Join Date
    03-16-2018
    Location
    London
    MS-Off Ver
    Office Excel 2013
    Posts
    4

    Re: Need your knowledge - vlookup with dynamic sheet reference VBA

    Hi Jindon!

    I'm very impressed, that works !!

    But i'm a little confused about what it does...

    So Array is used to store string value here.
    The line If temp will add a sheet after the one which come from the GetCurrentName function

    But about your Function:
    This line is confusing me :
    Please Login or Register  to view this content.
    Ucase$ is to convert a string to all uppercase, but i don't clearly understand the 2nd part, with the variable wsName, Like, and the "*"

    Anyway, thank you so much ! I can now finish my code

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: Need your knowledge - vlookup with dynamic sheet reference VBA

    Like operator accepts wild card characters.

    * any character(s) or none
    ? any one character
    # one numeric character

    also case sensitive.

    The function will get the last sheet that starts the element in the array, so if there are multiple such sheets, it will get the most right sheet name.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

+ 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. Dynamic Reference Vlookup VBA
    By penbeacho in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-11-2016, 07:13 PM
  2. a Dynamic Vlookup (Column Reference)
    By SunOffice in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-27-2013, 04:27 PM
  3. [SOLVED] Dynamic VLOOKUP wit INDIRECT reference
    By supern0va in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 08-29-2012, 11:44 AM
  4. Excel 2007 : Dynamic VLOOKUP reference
    By fuzzycells in forum Excel General
    Replies: 9
    Last Post: 11-30-2011, 05:43 AM
  5. vlookup dynamic reference
    By tknutsen in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-26-2008, 08:40 PM
  6. Dynamic range reference in VLOOKUP?
    By drhawk in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-09-2006, 10:21 AM
  7. Vlookup - dynamic range reference?
    By aseanor in forum Excel General
    Replies: 7
    Last Post: 08-17-2006, 06: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