Results 1 to 8 of 8

Thread: VBA to assign car parking spaces
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Sep 2019
    Posts
    4
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Lightbulb VBA to assign car parking spaces

    Hi,


    I'm pretty new to VBA, and was hoping someone might be able to help me with something i am trying to write:


    Sheet 1 (input tab): Row 1 contains Mon-Fri, with the rows below detailing what car parking spaces are available for those days, for example, if space 18 is available on monday cell A2 will say 18.


    Sheet 2 (parking list tab): this tab has employees in column A, column B dictates whether the employee needs a space or not, so they can be in a "space not needed" state, and then column C-G is the week days.


    What i wanted to do was update sheet1 with any available spaces for the week and then run a macro that would then assign the spaces to employees that require a space that week, so it would not assign to those in a "space not needed" state.


    I was hoping once this macro was run, sheet1 would contain no spaces so that if anymore spaces become available, we could update sheet1, run the macro, and the next employees due to receive a space would be allocated the space.


    I have no idea if this is possible, but i was hoping someone might be able to help?


    I look forward to any response


    Thanks,


    Adam

  2. #2
    Board Regular BlakeSkate's Avatar
    Join Date
    Jan 2015
    Location
    Pernsylvoonia
    Posts
    460
    Post Thanks / Like
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA to assign car parking spaces

    Quote Originally Posted by Adam0000007 View Post

    Sheet 1 (input tab): Row 1 contains Mon-Fri, with the rows below detailing what car parking spaces are available for those days, for example, if space 18 is available on monday cell A2 will say 18.
    so what happens when spaces 5,8,14 are also available?
    do you want A2 to display all numbers available on monday? will they be separated by any special characters or spaces? this is manually inputted?
    how many parking spots are there?
    -------------------------------------------------------------------------------
    I may not give the best VBA codes, but they sure are VBA codes.
    Help me help you by posting a snapshot of your data & your expected result
    Please use [ code][ /code] tags when posting VBA as well as proper indentation

  3. #3
    Board Regular BlakeSkate's Avatar
    Join Date
    Jan 2015
    Location
    Pernsylvoonia
    Posts
    460
    Post Thanks / Like
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA to assign car parking spaces

    Quote Originally Posted by Adam0000007 View Post
    What i wanted to do was update sheet1 with any available spaces for the week and then run a macro that would then assign the spaces to employees that require a space that week, so it would not assign to those in a "space not needed" state.
    if employee is "space not needed" does that mean on certain days or they just never need a space?

    Quote Originally Posted by Adam0000007 View Post
    and then column C-G is the week days.
    so the parking spot number thats available from sheet 1 will move to these columns i take it?
    what happens at the end of the week? do they keep the same parking schedule or does this reset weekly?
    -------------------------------------------------------------------------------
    I may not give the best VBA codes, but they sure are VBA codes.
    Help me help you by posting a snapshot of your data & your expected result
    Please use [ code][ /code] tags when posting VBA as well as proper indentation

  4. #4
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    28,019
    Post Thanks / Like
    Mentioned
    467 Post(s)
    Tagged
    47 Thread(s)

    Default Re: VBA to assign car parking spaces

    Cross posted https://www.excelforum.com/excel-pro...ng-spaces.html

    While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules).
    This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 365 on Win 10

  5. #5
    New Member
    Join Date
    Sep 2019
    Posts
    4
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA to assign car parking spaces

    "so what happens when spaces 5,8,14 are also available?
    do you want A2 to display all numbers available on monday? will they be separated by any special characters or spaces? this is manually inputted?
    how many parking spots are there?"

    So i would expect cell A3 to show 5, A4 to 8 etc etc, so it is in a list format.
    this list will be manually input.
    There are 200 parking spaces.

    "if employee is "space not needed" does that mean on certain days or they just never need a space?"

    When in this state, the employee does not need a space for that week.

    "so the parking spot number thats available from sheet 1 will move to these columns i take it?
    what happens at the end of the week? do they keep the same parking schedule or does this reset weekly?"

    yes i hope so, so there will be a list in sheet 1 with all the available spaces, and then the macro will allocate each space to the employees in sheet 2, in the order they are listed and not giving a space when in a "space not needed" state.
    And the end of the week the sheet will be reset, so sheet1 and sheet2 will be cleared out and the inputting of the manual data will begin again.

    I do have a blank version of the file but am unsure on how to attach this.

  6. #6
    New Member
    Join Date
    Sep 2019
    Posts
    4
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA to assign car parking spaces

    Apologies, i was unaware of the cross-posting rules:

    I also created these pages:
    https://www.excelforum.com/excel-pro...ng-spaces.html
    https://stackoverflow.com/questions/...parking-spaces

  7. #7
    Board Regular BlakeSkate's Avatar
    Join Date
    Jan 2015
    Location
    Pernsylvoonia
    Posts
    460
    Post Thanks / Like
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA to assign car parking spaces

    Quote Originally Posted by Adam0000007 View Post


    I do have a blank version of the file but am unsure on how to attach this.
    you can use dropbox etc and paste the link & i'll give it a looksie.
    are you open to changes if they make more sense?
    -------------------------------------------------------------------------------
    I may not give the best VBA codes, but they sure are VBA codes.
    Help me help you by posting a snapshot of your data & your expected result
    Please use [ code][ /code] tags when posting VBA as well as proper indentation

  8. #8
    New Member
    Join Date
    Sep 2019
    Posts
    4
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA to assign car parking spaces

    Thank you for your time, on the excel forum page i have been provided with a work around!

    I really do appreciate the time you took out to help though

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •