+ Reply to Thread
Results 1 to 3 of 3

A Macro that Populates Cells with a Formula

  1. #1
    Registered User
    Join Date
    01-17-2013
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    25

    A Macro that Populates Cells with a Formula

    Hi everyone, I have what should be an easy-to-answer question, but all my Google searches keep going in unproductive directions.

    Suppose in my worksheet, I have a tab named "FRUIT":

    ITEM ID_NUM PRICE RATING
    Apples 1001 2.00 20
    Oranges 1002 3.00 15
    Bananas 1003 1.50 30

    ...and so on. The purpose of "FRUIT" is to list all the fruit that my grocery store might carry. This information is static; it is never meant to be changed.

    Now suppose I have a second tab named "PLAN ORDER". This tab is supposed to pull data from the cells of "FRUIT" and allow the user to manipulate them:

    ITEM ID_NUM PRICE RATING
    =IFERROR(VLOOKUP($B1,'FRUIT'!$B$1:$D$4,1,0),"") =IFERROR(VLOOKUP($B1,'FRUIT'!$B$1:$D$4,2,0),"") =IFERROR(VLOOKUP($B1,'FRUIT'!$B$1:$D$4,3,0),"") =IFERROR(VLOOKUP($B1,'FRUIT'!$B$1:$D$4,4,0),"")
    =IFERROR(VLOOKUP($C1,'FRUIT'!$B$1:$D$4,1,0),"") =IFERROR(VLOOKUP($C1,'FRUIT'!$B$1:$D$4,2,0),"") =IFERROR(VLOOKUP($C1,'FRUIT'!$B$1:$D$4,3,0),"") =IFERROR(VLOOKUP($C1,'FRUIT'!$B$1:$D$4,4,0),"")
    =IFERROR(VLOOKUP($D1,'FRUIT'!$B$1:$D$4,1,0),"") =IFERROR(VLOOKUP($D1,'FRUIT'!$B$1:$D$4,2,0),"") =IFERROR(VLOOKUP($D1,'FRUIT'!$B$1:$D$4,3,0),"") =IFERROR(VLOOKUP($D1,'FRUIT'!$B$1:$D$4,4,0),"")

    I'm reasonably sure I've got that right. The above formulas should pull all the cell data from "FRUIT" to "PLAN ORDER". So once the above formulas are run, "PLAN ORDER" should actually look identical to "FRUIT", at least from the user's perspective:

    ITEM ID_NUM PRICE RATING
    Apples 1001 2.00 20
    Oranges 1002 3.00 15
    Bananas 1003 1.50 30

    Okay; from here, the user can change cell values, play around with the data, etc. My idea is that "FRUIT" would have permanent, static data, and and "PLAN ORDER" would be a copy of the data for the user.

    But what if the user wants to restore the original data in "PLAN ORDER"? After all once they start changing values, they are overwriting the original formulas. I need a micro that, when activated, simply rewrites the original formulas back into the "PLAN ORDER" cells:

    Please Login or Register  to view this content.
    But for the life of me, I can't figure out the syntax. Does anyone see where I'm going wrong? Thank you.
    Last edited by redapplesonly; 06-28-2022 at 12:49 PM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,426

    Re: A Macro that Populates Cells with a Formula

    Something like
    Please Login or Register  to view this content.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,426

    Re: A Macro that Populates Cells with a Formula

    Thanks for the rep.



    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

+ 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] Macro which populates Name Tags in Word
    By Melissa Camp in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-15-2019, 11:29 PM
  2. [SOLVED] Macro which populates Name Tags in Word
    By Melissa Camp in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-14-2019, 12:03 PM
  3. Dropdown Populates Two Cells at Once
    By HWScott in forum Excel General
    Replies: 1
    Last Post: 07-23-2016, 12:35 AM
  4. Formula/Macro that populates cells based on criteria
    By adroit233 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-21-2015, 05:49 AM
  5. Replies: 1
    Last Post: 08-28-2014, 12:48 AM
  6. [SOLVED] Vlookup Only Populates 2 of Many Cells - Rest are #N/A
    By motorsiklerider in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-30-2013, 04:04 PM
  7. Replies: 0
    Last Post: 07-11-2012, 01:42 PM

Tags for this Thread

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