+ Reply to Thread
Results 1 to 4 of 4

How do I keep a range automatically populated with a formula?

  1. #1
    Forum Contributor
    Join Date
    05-24-2006
    Location
    Los Angeles
    MS-Off Ver
    2019
    Posts
    328

    How do I keep a range automatically populated with a formula?

    Hi,

    Is there a way to have vba automatically keep a formula next of a dynamic column of cells?

    I have a database on a spreadsheet where the record number always changes and the date field column needs to be modified before I throw the whole thing into a pivot table. So, I created another date column adjacent to the database called "DateEOMONTH" where I have the EOMONTH function. What I need to do is figure out a a way to have that EOMONTH function (formatted as "mmm-yyy") added to or deleted from rows as the database increases or decreases in size.

    The column header cell for the Date field is named "DateStart", the DateEOMONTH header cell is named "DateEOMONTHStart", and the sheet where the database is located is Sheet11.

    Is there a cool vba way to do this or is this some kind of elaborate copy/paste solution?

    Thanks,

    Lawrence

  2. #2
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: How do I keep a range automatically populated with a formula?

    You don't specify which version of Excel you are using, but you might consider using either the List feature (Excel 2003) or the Table feature (Excel 2007) and basing the Pivot Table on the List/Table.

    Formula and formatting will be carried forwarded for new entries in the List/Table and, of course, if you delete a row or cells it will adjust.

    Create a Data List in Excel 2003

    Excel 2007 Tables
    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

  3. #3
    Forum Contributor
    Join Date
    05-24-2006
    Location
    Los Angeles
    MS-Off Ver
    2019
    Posts
    328

    Re: How do I keep a range automatically populated with a formula?

    I'm using 2003.

    Checked out the link...thanks!

    The List feature works great as the database grows, but if the database contracts (fewer rows), the DateEOMONTH column remains unchanged. The EOMONTH formulas after the last record still exist, they just reference blank cells where the deata extended before the database shrank. That's a problem because the pivot table will think therer are more records than there actually are.

    How do I get rid of those extra EOMONTH rows?

    Lawrence

  4. #4
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: How do I keep a range automatically populated with a formula?

    Remove the formulas from the cells and delete rows as needed. Let the List/Table feature carry formula and formatting forward to new records.

    Refresh the Pivot Table as required - can be automated via VBA. The PT will recognize the changes in the data table when adding/deleting rows.

+ 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