+ Reply to Thread
Results 1 to 4 of 4

Copying Down VLOOKUP formula in VBA

  1. #1
    Forum Contributor
    Join Date
    02-24-2008
    Location
    UK
    MS-Off Ver
    2012 and 2016
    Posts
    123

    Copying Down VLOOKUP formula in VBA

    I have a spreadsheet that uses VLOOKUP to automatically look up values (£:p) in 12 monthly sheets - Nov 16 to Oct 17 for each person on the list - see image VLOOKUP - Table of Values (1). A have a number of separate sheets like the one shown in the image that add up the values for each person for particular events (such as "Past Captains Match", "Subscription", etc). Everything works fine until I use VBA code to add a new name to each sheet. The inserted name does not refer to the values in the 12 monthly sheets because the relevant VLOOKUP formula is not inserted against their name - see image VLOOKUP - Table of Values (2). Here is part of the VBA code that I use to insert a new name:

    Please Login or Register  to view this content.
    Is there a way of modifying the above VBA code so that the correct VLOOKUP formula is inserted next the the added name?

    Thanking you in anticipation.
    Attached Images Attached Images

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: Copying Down VLOOKUP formula in VBA

    There may be a non-VBA, simpler way to do this with formulas and names ranges. Is that something you would consider?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Forum Contributor
    Join Date
    02-24-2008
    Location
    UK
    MS-Off Ver
    2012 and 2016
    Posts
    123

    Re: Copying Down VLOOKUP formula in VBA

    I use command buttons linked toVBA code to add and delete names from 12 monthly sheets and 6 event sheets. this cuts down on the effort needed and ensures that all the names are exactly the same (needed for VLOOKUP function). I could simply drag the VLOOKUP formula on each of the relevant worksheets but I wanted to do this automatically when the name is added.

    Can this be done using formulas and names ranges as suggested?
    Last edited by kencoburn; 03-19-2017 at 05:01 AM.

  4. #4
    Forum Contributor
    Join Date
    02-24-2008
    Location
    UK
    MS-Off Ver
    2012 and 2016
    Posts
    123

    Re: Copying Down VLOOKUP formula in VBA

    I got no response to my last request for advice and so I spent time trying to work it out for myself.
    I wanted to ensure that the correct VLOOPUP formula was placed next to the added name. The above code leaves
    the cell blank. It was possible to do this manually by dragging down the formula from the cell above and so
    I used the macro recorder to see what happened to the underlying VBA code. This is what I found:

    ' Copy down formula from previous row cell

    Please Login or Register  to view this content.
    I added this code to my VBA code and it worded a treat:

    Please Login or Register  to view this content.
    I hope that helps anyone else with the same problem.

+ 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. Vlookup not copying down
    By tryer in forum Excel General
    Replies: 4
    Last Post: 12-12-2019, 02:56 AM
  2. [SOLVED] Copying formula result to new cell, without copying formula itself
    By nappyjim1 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-19-2016, 02:24 AM
  3. VLOOKUP for copying and pasting?
    By pwells in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-27-2014, 04:00 PM
  4. Replies: 5
    Last Post: 01-10-2012, 05:49 PM
  5. Replies: 6
    Last Post: 01-10-2012, 10:53 AM
  6. [SOLVED] copying vlookup function across
    By Ramzes in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-10-2010, 07:57 AM
  7. [SOLVED] copying VLOOKUP
    By Jane in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-25-2006, 10:15 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