+ Reply to Thread
Results 1 to 15 of 15

Automatic fill of a cell with with days in the month

  1. #1
    Forum Contributor
    Join Date
    04-09-2010
    Location
    Fort Myers, FL
    MS-Off Ver
    Excel for MAC
    Posts
    146

    Automatic fill of a cell with with days in the month

    I have a drop down list in cell F1 with all the months. In G1, I would like it to automatically display the number of days in the selected month. Of course it depends on the current year (due to leap year, etc).

    Thank you in advance!
    Nick

  2. #2
    Forum Expert RobertMika's Avatar
    Join Date
    06-22-2009
    Location
    Haverhill, UK
    MS-Off Ver
    Excel 2003-13
    Posts
    1,530

    Re: Automatic fill of a cell with with days in the month

    Are your months in Text or Date format?
    If you are http://www.excelforum.com/image.php?type=sigpic&userid=125481&dateline=1392355029happy with the results, please add to the contributor's
    reputation by clicking the reputation icon (star icon).




    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.
    To undo, select Thread Tools-> Mark thread as Unsolved.
    http://www.excelaris.co.uk

  3. #3
    Forum Contributor
    Join Date
    04-09-2010
    Location
    Fort Myers, FL
    MS-Off Ver
    Excel for MAC
    Posts
    146

    Re: Automatic fill of a cell with with days in the month

    Text, January, February, etc

    Thank you.

  4. #4
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Automatic fill of a cell with with days in the month

    one way with text months jan/feb or january,february...........=EOMONTH(VALUE("1/"&F1&YEAR(TODAY())),0) format cell as custom dd
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  5. #5
    Forum Contributor
    Join Date
    04-09-2010
    Location
    Fort Myers, FL
    MS-Off Ver
    Excel for MAC
    Posts
    146

    Re: Automatic fill of a cell with with days in the month

    Quote Originally Posted by martindwilson View Post
    one way with text months jan/feb or january,february...........=EOMONTH(VALUE("1/"&F1&YEAR(TODAY())),0) format cell as custom dd
    Beautiful.. that is perfect! So the year will continually change because of "YEAR(TODAY)" right? Awesome. Thank you!

  6. #6
    Forum Expert RobertMika's Avatar
    Join Date
    06-22-2009
    Location
    Haverhill, UK
    MS-Off Ver
    Excel 2003-13
    Posts
    1,530

    Re: Automatic fill of a cell with with days in the month

    Slightly quicker
    =EOMONTH(--("1/"&F1&YEAR(TODAY())),0)

  7. #7
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Automatic fill of a cell with with days in the month

    Here's another one...

    =DAY(EOMONTH("1/"&F1&YEAR(NOW()),0))

    Format as General or Number
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  8. #8
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Automatic fill of a cell with with days in the month

    Quote Originally Posted by nkitchen31 View Post
    So the year will continually change because of "YEAR(TODAY)" right?
    Yes.

    You can substitute NOW() for TODAY() and it will still work.

  9. #9
    Forum Contributor
    Join Date
    04-09-2010
    Location
    Fort Myers, FL
    MS-Off Ver
    Excel for MAC
    Posts
    146

    Re: Automatic fill of a cell with with days in the month

    Thank you for all the replies… Now…

    Is it possible now to protect just that one cell with the formula in it so somebody doesn't accidentally change it who doesn't know better?

    I went to protect worksheet in the Tools menu, but then when I chance the month in the drop down list, it says the sheet is protected and it won't change the value.

    Thanks again.

  10. #10
    Forum Contributor
    Join Date
    04-09-2010
    Location
    Fort Myers, FL
    MS-Off Ver
    Excel for MAC
    Posts
    146

    Re: Automatic fill of a cell with with days in the month

    Nevermind, I got it .. it was still "Locked".

  11. #11
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Automatic fill of a cell with with days in the month

    Quote Originally Posted by nkitchen31 View Post

    I went to protect worksheet in the Tools menu...
    What version of Excel are you using?

    Your profile says Excel 2010 but it doesn't have a Tools menu.

  12. #12
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Automatic fill of a cell with with days in the month

    Good deal. Thanks for the feedback!

  13. #13
    Forum Contributor
    Join Date
    04-09-2010
    Location
    Fort Myers, FL
    MS-Off Ver
    Excel for MAC
    Posts
    146

    Re: Automatic fill of a cell with with days in the month

    Tony.. done!

    Okay, so now that I formatted that as "dd", I cannot reference that cell in the formula for another cell because it uses the value "41,350" or something instead of 31 … Any ideas how to change that?

    Thanks.

  14. #14
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Automatic fill of a cell with with days in the month

    =DAY(EOMONTH("1/"&F1&YEAR(NOW()),0)) which tony suggested

  15. #15
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    Office 2021
    Posts
    2,237

    Re: Automatic fill of a cell with with days in the month

    I think we don't need YEAR(TODAY()) here. If we omit that excel will consider that is from current year.

    =DAY(EOMONTH(1&F1,0))
    Regards,
    Haseeb Avarakkan

    __________________________________
    "Feedback is the breakfast of champions"

+ 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] How do I get Excel to automatically fill in the days of a month in a Column.
    By knightrider1956 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-15-2013, 04:05 AM
  2. Auto Fill days of the Month
    By jj72uk in forum Excel General
    Replies: 5
    Last Post: 11-30-2009, 12:38 PM
  3. Pre fill set range off cells with the days of the month
    By Dragonjimbob in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-01-2009, 09:03 AM
  4. function to fill all days of month to end of month
    By Monique in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 05-01-2006, 02:45 PM
  5. [SOLVED] function to fill all days of month to end of month
    By YaHootie in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 05-01-2006, 01:10 AM

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