+ Reply to Thread
Results 1 to 16 of 16

Autopopulate (horizontally) cells in calendar via UserForm

  1. #1
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Autopopulate (horizontally) cells in calendar via UserForm

    Hi,

    I have a file with some sheets, one sheet for every month-the days from 1-31 are populate via UserForm, one sheet a sort of control/summary, a sheet for public holidays.
    When a guy wants a vacation I wanna type the date in a textbox and the required days in another one.
    I want to populate horizontally the cells when the values are entered in textbox (the date) and the rq days excluding the weekends and the public hol.
    I tried different methods but unsuccessful.
    also posted here
    http://www.thecodecage.com/forumz/forumdisplay.php?f=64

    I really appreciate your help!
    Attached Files Attached Files
    Regards, John55
    If you have issues with Code I've provided, I appreciate your feedback.
    In the event Code provided resolves your issue, please mark your Thread as SOLVED.
    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

    ...enjoy -funny parrots-

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Autopopulate (horizontally) cells in calendar via UserForm

    Hi John

    This formula calculates the 20th workday after the date in A1m Easily adaptable to meet your requirement.

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Autopopulate (horizontally) cells in calendar via UserForm

    Hi John

    This formula calculates the 20th workday after the date in A1m Easily adaptable to meet your requirement.

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  4. #4
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: Autopopulate (horizontally) cells in calendar via UserForm

    Hi mehmetcik,
    Thanks for your solution, I do not want to count the days (yet), let's say a guy wants to take a vacation starting from 10apr for 10days. there is weekend and public holiday, is possible to put a "C" for each day writing the date in textbox and the days only?

  5. #5
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Autopopulate (horizontally) cells in calendar via UserForm

    I looked at your userform and workbook found them to be overcomplicated.

    That is why I gave you the formula.

    Try this

    If the Textbox1 contains your Start Date and Textbox 2 = your Number of days Holiday then

    Clicking on Command Button 1 will populate your worksheets.

    Please Login or Register  to view this content.
    Last edited by mehmetcik; 12-27-2016 at 07:00 PM.

  6. #6
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: Autopopulate (horizontally) cells in calendar via UserForm

    Hi mehmetcik,

    I think I am or you, not sure which one, or both lol, so we are on the right way! Thank you very much for your solution!
    I tried it and whatever the month is chosen (I tried with APR or DEC), it populates the cells in JAN without taking into account the weekends....

  7. #7
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Autopopulate (horizontally) cells in calendar via UserForm

    I ignored the weekends in my first Pass of the code.

    I think that the next stage would be to replace the lines that fill the worksheets with a C with a subroutine.

    Such as:-

    Please Login or Register  to view this content.


    So your code becomes:-

    Please Login or Register  to view this content.
    Last edited by mehmetcik; 12-28-2016 at 03:58 PM.

  8. #8
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: Autopopulate (horizontally) cells in calendar via UserForm

    Hi,
    Please Login or Register  to view this content.
    soryy can not see why the fillcode is in red...

  9. #9
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Autopopulate (horizontally) cells in calendar via UserForm

    My Mistake

    I wrote the code from memory.

    Try

    Please Login or Register  to view this content.

  10. #10
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: Autopopulate (horizontally) cells in calendar via UserForm

    Thank you!
    it seems it takes into account the weekends, but it populate Jan month only! ...sometimes it jumps to Dec month!

  11. #11
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Autopopulate (horizontally) cells in calendar via UserForm

    Hi John

    I have stripped out all the code in your original spreadsheet.

    I have also removed your userform.

    So we can concentrate on the area of code that we are interested in.

    This seems to work now.

    Clicking on the button in Jan will open up a simple useform, Preloaded with 20/12/2016 and 20

    Clicking on the button on the Userform will select sheet DEC and will fill ehe workdays from 20/12 to 31/12 with a C

    It will then Select sheet Jan and continue.


    Change the 20 to 40 and run the macro, the end date will now be 22nd Feb

    NB: once we have tested it removing .select will stop the macro switching sheets and make the macro faster and smoother.
    Attached Files Attached Files
    Last edited by mehmetcik; 12-29-2016 at 08:16 AM.

  12. #12
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: Autopopulate (horizontally) cells in calendar via UserForm

    Hi,
    excellent! the way is really good!
    but I noticed that even if we have 20 days, it fills more than 20 working days, it exclude the weekends but not the public holidays.
    I tried to skip'em taking into account the cell's color (using offset) but it is difficult with 2 colors (weekends and pbl hol)

  13. #13
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Autopopulate (horizontally) cells in calendar via UserForm

    Hi George

    I see how you want to deal with Public Holidays.

    Try changing the new subroutine to:-

    Please Login or Register  to view this content.
    Your Public Holidays are listed in the Array Hoiday.

    Please Login or Register  to view this content.
    These relate to:-
    26/12/2016 27/12/2016 02/01/2017 03/01/2017


    Your Main code needs some other chages to:-

    Please Login or Register  to view this content.

    I think that the final change is to change how you name your sheets:

    ie Dec should be Dec:2016 followed by Jan:2017

    That will need the code to be modified but that should be quite easy.


    Oh, one point.

    I think you should put this formula in Cell AU12 on sheet JAN-2017 and fill it down
    Attached Files Attached Files
    Last edited by mehmetcik; 12-29-2016 at 07:22 PM.

  14. #14
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: Autopopulate (horizontally) cells in calendar via UserForm

    Hi,

    Thank you! Better 'n better!!!
    the month is chosen correctly, it goes to the next month if it requires but it doesn't exclude de hol. I created the array for hol I tried with range but the result was the same, ignored'em!
    I attach 2 pics, dec (see holidays 25 and 26dec) and sep (I wanted 5 days and I received 6 days lol)

    dec.PNG
    sep.PNG

    Thx again!

  15. #15
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286

    Re: Autopopulate (horizontally) cells in calendar via UserForm

    Have a quick look at this method and see if it can be adapted....I cant remember how far I got with it....
    Attached Files Attached Files

  16. #16
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: Autopopulate (horizontally) cells in calendar via UserForm

    Hi nigelog,
    Thank you for your solution, I tried one before but I want to have in the same file/sheet the roster!
    I know, it's a complicated file, actually it's a huge file, the vacation part is a small part of it! I hope the guys from this forum can help me to solve this issue....in order to have "all in one"!
    Thx again!

+ 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. How to get excel to autopopulate formula horizontally.
    By needhelpthanks in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 12-26-2016, 08:53 PM
  2. [SOLVED] Autopopulate Excel Calendar with Data Ranges
    By hlmmc in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-12-2016, 07:50 PM
  3. [SOLVED] How to autopopulate calendar with data from different sheet
    By marcella needs help in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-20-2016, 06:07 AM
  4. [SOLVED] Autopopulate macro, needs to searrch for appropriate section to autopopulate
    By Butcher1 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-09-2015, 09:11 AM
  5. [SOLVED] IFERROR autopopulate code isn't bringing the right text from list tab to calendar tab
    By nkicroft in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-05-2014, 02:43 PM
  6. [SOLVED] Userform to autopopulate workbook, date not working
    By cath1509 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-03-2013, 04:47 PM
  7. Replies: 1
    Last Post: 10-30-2012, 02:05 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