+ Reply to Thread
Results 1 to 5 of 5

Macro to insert list of dates with conditions

  1. #1
    Forum Contributor
    Join Date
    11-26-2008
    Location
    UK
    MS-Off Ver
    Using Excel 2019
    Posts
    317

    Macro to insert list of dates with conditions

    Hi,

    I wonder if someone could help me with a macro?

    I have one empty row (B3:K3) and one column (M4:M16) which the user populates with dates. There will be the same number of cells in the rows as there are cells in the columns. I also have a 'today's date' cell (M3) which displays, ermm today's date!

    What i'd like to happen is everytime the worksheet is opened for the row (B3:K3) to be populated with the dates in (M4:M16). However it most only populate those empty cells with dates that are before and include today's date - and in the same order (NOT date order) that they appear in the column.

    I've attached a small example spreadsheet of dates in the column that are entered and the blank fields in the row.

    Dates.xlsx
    Last edited by Barking_Mad; 10-23-2013 at 05:24 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    10-26-2008
    Location
    Birmingham, UK
    MS-Off Ver
    All versions up to 2010
    Posts
    1,025

    Re: Macro to insert list of dates with conditions

    Hi
    If I understand your question clearly you can do this without a macro. See solution attached.
    Good luck.
    Tony
    Attached Files Attached Files

  3. #3
    Forum Contributor
    Join Date
    11-26-2008
    Location
    UK
    MS-Off Ver
    Using Excel 2019
    Posts
    317

    Re: Macro to insert list of dates with conditions

    Hi ARGK. Thanks for that.

    Taking it just one step further can you help me work out how to get it to count the instances of the letter "n" that fall between the first date and the last date and all the students in the vertical column. So for instance in the attached example it should count 8 instances of "'n" in the table and not the other 6 instances the columns beyond the last date.

    Dates.xlsx

  4. #4
    Valued Forum Contributor
    Join Date
    10-26-2008
    Location
    Birmingham, UK
    MS-Off Ver
    All versions up to 2010
    Posts
    1,025

    Re: Macro to insert list of dates with conditions

    Hi
    See example without using a macro you can use formulae. In range B2 to N2 I have put a formula in each of the cells to count the number of entries in each column that are equal to "n". Each subsequent column adds the previous column value so you have a running total. You just need to read the value above the last column that has a date in it.
    Hope this helps.
    Good luck.
    Tony
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    11-26-2008
    Location
    UK
    MS-Off Ver
    Using Excel 2019
    Posts
    317

    Re: Macro to insert list of dates with conditions

    Hi,

    This equation does the trick - with the cells chosen as being the ones above the row where the final value is situated.

    Please Login or Register  to view this content.

+ 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. Macro to insert rows and columns using a value from the drop down list
    By Oscar Bruno in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-15-2013, 01:52 PM
  2. Need Macro to insert a Specific number of Rows (in Filtered list)
    By JTwrk in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-09-2012, 08:05 PM
  3. Macro to list out items with conditions
    By Saky in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-03-2011, 10:26 AM
  4. Insert list of dates from a my WKS
    By harryhill in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-16-2007, 01:48 AM
  5. Excel Macro to insert rows in a list
    By MartyCole in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-13-2005, 03:06 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