+ Reply to Thread
Results 1 to 7 of 7

Macro to write a formula with dynamic cell references

  1. #1
    Registered User
    Join Date
    12-27-2012
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2007
    Posts
    21

    Macro to write a formula with dynamic cell references

    Hi there,

    I have a spreadsheet that retains production information (in pivot form)for each business day on a sheet called "Daily Data Aggregation". I then plot this information on a chart and re-manipulate the data (using a VLOOKUP) into a different format on a sheet called "Chartable Data". I am trying to write a macro that will search the first row of the "Chartable Data" tab for today's date, and then when it finds it, input the following formula one cell below: =IFERROR(VLOOKUP($A2,'Daily Data Aggregation'!$B$12:$D$22,3,FALSE)/1000000,0). The trick here is that I need the red "table array" portion to change so that it is reading the today's retained production information from the "Daily Data Aggregation" tab. After this is done, I would love it it could copy the formula down just changing the row reference by one until it reaches the row that says "Total".

    I tried to write two macros but I wasn't having any luck. They are below. Perhaps someone here could give me some guidance?

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Thanks,

    Jordan
    Attached Files Attached Files
    Last edited by alpha608; 03-27-2013 at 12:19 PM.

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: Macro to write a formula with dynamic cell references

    Hi

    Using your example file, select cell 'Charatible Data'!D2 (or A2, or B2....) and run

    Please Login or Register  to view this content.
    See how that goes.

    rylo

  3. #3
    Registered User
    Join Date
    12-27-2012
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Macro to write a formula with dynamic cell references

    It is doing what I am looking for. One question: is it possible to do that without having to select 'Chartable Data'!D2 ?

  4. #4
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: Macro to write a formula with dynamic cell references

    Hi

    Sure, but you would need to have some parameters on exactly what you want it to fill. Do you want it to fill all the items in row 2 or just any blank items from row 2 where there is a heading in row 1?

    rylo

  5. #5
    Registered User
    Join Date
    12-27-2012
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Macro to write a formula with dynamic cell references

    On the 'Chartable data' sheet if the current date is the same as what is displayed in row 1, I would like to input this formula into the cell below the current date (row 2).

    Does that make sense?

  6. #6
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: Macro to write a formula with dynamic cell references

    Hi

    this does assume that you will have today's date in row 1 of Chartable Data, and there will be data for it on Daily Data Aggregation

    Please Login or Register  to view this content.
    rylo

  7. #7
    Registered User
    Join Date
    12-27-2012
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Macro to write a formula with dynamic cell references

    Hi rylo,

    This works well. Thanks!

    Jordan

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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