+ Reply to Thread
Results 1 to 17 of 17

VBA to assign car parking spaces

  1. #1
    Registered User
    Join Date
    09-03-2019
    Location
    Birmingham, England
    MS-Off Ver
    2016
    Posts
    9

    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
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,742

    Re: VBA to assign car parking spaces

    Could you attached sample file, please?
    Also describe inside expected results (how output data should looks like - cells & values).

    Please check Forum rules #3 - cross-post.
    Here : https://www.mrexcel.com/forum/excel-...ng-spaces.html
    Last edited by KOKOSEK; 09-03-2019 at 10:32 AM.
    Happy with my answer * Add Reputation.
    If You are happy with solution, please use Thread tools and mark thread as SOLVED.

  3. #3
    Registered User
    Join Date
    09-03-2019
    Location
    Birmingham, England
    MS-Off Ver
    2016
    Posts
    9

    Re: VBA to assign car parking spaces

    Hi,

    I have attached a file (hopefully!)

    basically, on the input tab, you can see in each column what spaces are currently available that day, and what i want the code to do is allocate the available space on the temporary parking list tab to person 1 etc etc...
    on the temporary parking list tab there is a space not needed criteria, so i was hoping to macro would not give a space to people who had this populated in column B.
    So from the attachment, i would expect cell D9 to have 7, as this is the first space on the input tab on Monday and person 8 is the first person who requires a space.

    Thanks,
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    09-03-2019
    Location
    Birmingham, England
    MS-Off Ver
    2016
    Posts
    9

    Re: VBA to assign car parking spaces

    p.s. do let me know if that still is insufficient, i can try and write it better.

    I did miss out in my previous post where i would like the input tab to be clear once the macro has been ran, so new spaces that become available can then be entered in the input and the macro can be ran again to allocate these spaces to the next person on the list.

    Thanks,

  5. #5
    Registered User
    Join Date
    09-03-2019
    Location
    Birmingham, England
    MS-Off Ver
    2016
    Posts
    9

    Re: VBA to assign car parking spaces

    Apologies, i was unaware of the cross-posting rules, i have also created these pages:

    i am unable to post the links due to the following error:

    "The following errors occurred with your submission
    You are not allowed to post any kinds of links, images or videos until you post a few times."

  6. #6
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,212

    Re: VBA to assign car parking spaces

    I am unclear from your sheet, how is a space that is not needed identified? it appears they are shaded gray from your list sheet, but your answer suggest they are the 2 paler colours

    are you just wanting to go down the column and fill the non dark gray cells with the people who require parking?

    If you have not been able to allocate spaces you want to plabk the input tab?


    your sample is small, create an after sheet for how you wish the temporary parking sheet to look after the macro has run

  7. #7
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,742

    Re: VBA to assign car parking spaces

    I don't know, probably correct (if I correctly read your needs):


    A
    B
    C
    D
    E
    F
    G
    H
    1
    Full Name Space not needed Email Monday 19/08/2019 Tuesday 20/08/2019 Wednesday 21/08/2019 Thursday 22/08/2019 Friday 23/08/2019
    2
    Person 1 Space not needed
    3
    Person 2
    7
    8
    1
    12
    15
    4
    Person 3
    8
    9
    10
    51
    58
    5
    Person 4
    15
    81
    100
    77
    11
    6
    Person 5 Space not needed
    7
    Person 6 Space not needed
    8
    Person 7 Space not needed
    9
    Person 8 Space not needed
    10
    Person 9 Space not needed
    11
    Person 10
    51
    100
    7
    12
    12
    Person 11 Space not needed
    13
    Person 12
    12
    112
    18
    99
    14
    Person 13 Space not needed
    15
    Person 14
    24
    98
    1
    16
    Person 15 Space not needed
    17
    Person 16
    26
    2
    18
    Person 17 Space not needed
    19
    Person 18
    98
    4
    20
    Person 19 Space not needed
    21
    Person 20
    5
    22
    Person 21 Space not needed
    23
    Person 22
    8
    24
    Person 23
    Sheet: Temporary Parking List

    Array formula (needs accept with Ctrl+Shift+Enter) into D9:

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

    drag right and down (and 8 up :-))

    Check attached file.
    Attached Files Attached Files
    Last edited by KOKOSEK; 09-03-2019 at 11:47 AM.

  8. #8
    Registered User
    Join Date
    09-03-2019
    Location
    Birmingham, England
    MS-Off Ver
    2016
    Posts
    9

    Re: VBA to assign car parking spaces

    Yeah that works
    Thank you for putting up with me, i will improve the way i request help going forwards.

  9. #9
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,027

    Re: VBA to assign car parking spaces

    Here is the cross-post (at least one... were there more??).

    DO NOT cross post without disclosing the cross-posts. This can be a total time waster for the folk who give you some of their time, for free, each and every day. Show them some courtesy and declare cross-posts.

    https://www.mrexcel.com/forum/excel-...ng-spaces.html
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  10. #10
    Registered User
    Join Date
    09-03-2019
    Location
    Birmingham, England
    MS-Off Ver
    2016
    Posts
    9

    Re: VBA to assign car parking spaces

    yes the other was on stack overflow.

    And i understand that people are offering their time for free and i will not cross post again

  11. #11
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,027

    Re: VBA to assign car parking spaces

    There's no problem about cross-posting... unless you keep it a secret!!

  12. #12
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,078

    Re: VBA to assign car parking spaces

    For reference this is the one on stack
    https://stackoverflow.com/questions/...parking-spaces

  13. #13
    Registered User
    Join Date
    09-03-2019
    Location
    Birmingham, England
    MS-Off Ver
    2016
    Posts
    9

    Re: VBA to assign car parking spaces

    Hi,

    I unfortunately forgot that a person is able to not require a space for just one day of the week, in this instance they will have an "x" placed in whatever day they do not require a space on sheet 2 (Temporary Parking List).

    So looking in the attachment, person 11 has an x placed on Wednesday (F12), so due to this, space 100 on sheet1(Input) is now no longer being allocated.

    is there any way to allow for this? So essentially i want something that would allocate all the available spaces on the input tab but be intelligent enough to see that there is an x so do not allocate a space on this day to this person.

    Thank you for any help and apologies for missing this in my initial requirements.

    Thanks,

    Adam
    Attached Files Attached Files

  14. #14
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,304

    Re: VBA to assign car parking spaces

    Is there a maximum number of spaces and maximum number of persons.
    torachan.

  15. #15
    Registered User
    Join Date
    09-03-2019
    Location
    Birmingham, England
    MS-Off Ver
    2016
    Posts
    9

    Re: VBA to assign car parking spaces

    The spaces range from 1-200 and also T1-T100, as there are 2 car parks. So spaces can be any number between 1-200 and T1-T100.
    The maximum number of persons will be the amount of employees at that site, so approximately 1000.

  16. #16
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: VBA to assign car parking spaces

    Macro will allot numbers in Input Sheet.
    Macro code for Parking allotment.
    Please Login or Register  to view this content.
    Last edited by kvsrinivasamurthy; 09-05-2019 at 11:09 AM.
    Pl note
    Array formula should be confirmed with Ctrl+Shift+Enter keys together.
    If answere is satisfactory press * to add reputation.

  17. #17
    Registered User
    Join Date
    09-03-2019
    Location
    Birmingham, England
    MS-Off Ver
    2016
    Posts
    9

    Re: VBA to assign car parking spaces

    Ok from first checks that looks to be doing exactly what i want! Thank you so much

+ 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] Calculate aircraft parking time
    By vba1234 in forum Excel Formulas & Functions
    Replies: 30
    Last Post: 05-25-2018, 09:53 AM
  2. Rotating Parking List
    By Adamba in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 05-10-2018, 06:17 AM
  3. Counting Occupancy of Parking Garage
    By tycush7 in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 12-07-2016, 12:46 AM
  4. [SOLVED] Parking Schedule
    By warmanj in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 07-28-2016, 04:42 PM
  5. Car Parking Schedule...
    By it02s28 in forum Excel General
    Replies: 1
    Last Post: 06-12-2015, 08:53 PM
  6. Converting Addresses to Parking Spaces
    By SoothSailor in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-08-2015, 09:12 AM
  7. parking the cursor using VBA - listbox
    By Shela in forum Excel General
    Replies: 0
    Last Post: 09-09-2008, 11:24 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