+ Reply to Thread
Results 1 to 9 of 9

Help creating a worload list for undividual people based on data in different sheets.

  1. #1
    Registered User
    Join Date
    04-11-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2003
    Posts
    5

    Help creating a worload list for undividual people based on data in different sheets.

    Hello and thanks for looking !

    I am part of a small team doing some work in a lab. We the users in the workbook are "allocated" to various parts of the site to undertake tasks. These tasks are scheduled, and its proving a tad difficult to keep track of all the changes in site allocation and when who has to do what task ....

    I thought I would try and make our lives a little easier by getting the information together in a spreadsheet workbook and manipulate it so that each user can have their own list of tasks with the months they have to complete the tasks within. As the users can be rotated through the sites depending on work load and the number of people available each quarter, I thought of trying to use formulas to update the user sheets as is necessary. This would allow (hopefully) if any change made to the site allocation in "site_user" sheet, it would filter through to the "site_schedule" scheduling sheet, which would then allow individual user sheets to be populated with the tasks they have been assigned for that month.

    I fear I've definitely bitten off more than I can chew. Formulas are OK, but I'm new to the whole VB aspect and would like to dip my toe into the waters so to speak.

    I started off with the attached workbook as my template to play about with.

    site_user
    This will be where i can place users against sites to which they have been allocated. This will be used to populate a column in the "site_schedule"

    site_Schedule
    This contains a list of tasks and the months they have to be completed within. This sheet would look to site_user sheet and populate names against the site scheduled months.

    user
    This would be a sheet that each user can print off for their own records. If a change was made to the site_user sheet, it would be good to have it filter down and change the site allocation in site_schedule and then cascade the changes to the user sheets so that new ones can be printed off.

    My train of thought on how I can approach this would be as follows.
    • To have a nested loop that would compare each site scheduled in the site_schedule sheet to the site user sheet. Where a match is found, the formula would copy the user from the site_user sheet and place their name against the scheduled site task in site_schedule.
    • When the loop exits, a second sub formula would then run through the site_schedule sheet and, based on the user name, populate an individualized sheet for each user that they can then print off.
    • Id use a sheet reset command to reset each sheet (before the other sub functions are run) when the file is opened so that changes can be made to the site_user sheet, save the sheet then open it again and the other sub functions could then populate a clean user sheet rather than just appending at the bottom. I know you can use a button to do this but Im a complete beginner when it comes to visual basic. Did some actual basic well back in the day but thats about the extent of my experience.


    Am I barking up the right tree ? or has my logic in how to get the job done a touch disjointed ?

    Sorry this is a long post, thought it best to say exactly where I was going with my ramblings rather than ask a vague question.
    Attached Files Attached Files
    Last edited by Clyde Daleton; 04-11-2013 at 04:47 PM. Reason: typos, all thumbs this evening

  2. #2
    Registered User
    Join Date
    04-11-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Help creating a worload list for undividual people based on data in different sheets.

    Thought that I would keep my thread going with the progress I'm making. I have had success in creating a small sub to populate the site_schedule list. Now going for the kill and seeing if I can get the single script to populate the user1 user2 and user3 sheets as it populates the schedule table.

    If I can I will get the sub to reset the users sheet and populate it with their tasks as it allocates.

    Current code as follows.

    Sub update_user()
    Dim schednum As Integer 'only a whole number
    Dim sitenum As Integer 'only a whole number
    Dim r1 As Integer 'only a whole number
    Dim r2 As Integer 'only a whole number
    Dim found As Boolean 'only true or false

    schednum = Application.WorksheetFunction.CountA(Worksheets("site_schedule").Columns(2)) - 1 'check the number of scheduled items
    sitenum = Application.WorksheetFunction.CountA(Worksheets("site_user").Range("b:b")) - 1 'check the number of sites

    ' For each entry in the second worksheet, see if it's
    ' in the first.
    For r2 = 1 To schednum
    found = False
    Worksheets("site_schedule").Cells(1, 4) = found 'just here to check the numbers as we go
    Worksheets("site_schedule").Cells(2, 6) = r2 'just here to check the numbers as we go
    Worksheets("site_schedule").Cells(2, 5) = sitenum 'just here to check the numbers as we go
    ' See if the r1-th entry on sheet 2 is in the sheet
    For r1 = 1 To sitenum ' 1 list.
    Worksheets("site_schedule").Cells(1, 5) = r1 'just here to check the numbers as we go
    Worksheets("site_schedule").Cells(1, 6) = schednum 'just here to check the numbers as we go
    If Worksheets("site_user").Cells(r1 + 3, 2) = Worksheets("site_schedule").Cells(r2 + 3, 2) Then
    ' If a match is found
    found = True
    Worksheets("site_schedule").Cells(r2 + 3, 1) = Worksheets("site_user").Cells(r1 + 3, 1)
    Exit For 'no point in doing the rest if we found a match
    End If
    Next r1
    If Not found Then 'will colour a cell if there is a site with noone allocated to it
    Worksheets("site_schedule").Cells(r2 + 3, 2).Interior.ColorIndex = 35
    End If
    Next r2
    End Sub

    As Im still learning Im keeping in the quotes to remind me when I go back to look, that and I've placed in a number of functions to populate certain cells for debug purposes. Apologies for the formatting. I didnt see a quote tab in the editor to make it look as it does in Excel.

    Will update when I get the next bit working.

    -CD
    Attached Files Attached Files

  3. #3
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Help creating a worload list for undividual people based on data in different sheets.

    Looks like you're heading in the right direction... Let us know if you hit any snags..
    Elegant Simplicity............. Not Always

  4. #4
    Registered User
    Join Date
    04-11-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Help creating a worload list for undividual people based on data in different sheets.

    Im making progress slowly but surely. I have unfortunately hit a snag.

    What I would like the script to do is to populate the users sheet with the scheduled task as it is going through and populating users to the site_schedule sheet. The name of the users sheet would vary depending on where it is in matching users to scheduled tasks. I thought I could use a variable in worksheets() to find the last row in the users sheet by using the following

    Please Login or Register  to view this content.
    Unfortunately it spits the dummy so to speak.

    Current itteration of the code is as follows.
    Please Login or Register  to view this content.

  5. #5
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Help creating a worload list for undividual people based on data in different sheets.

    To find the next empty row in a table try
    Dim Lastrow as long
    LastRow = Sheet1.Cells(Rows.Count, "A").End(xlUp).Row +1

  6. #6
    Registered User
    Join Date
    04-11-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Help creating a worload list for undividual people based on data in different sheets.

    Thanks for the tip, incorporated the style into the script.

    Im keen on using a variable as the "sheet1" for me would be a variable based on what user is being matched at that part of the script. All users sheets will be the users names. This way I thought that when a site is found to have a user, it would place the users name against the site in the site_schedule, and at the same time add the scheduled task to the users sheet.

    I managed to do it using a further loop, though I know this could get a touch unwieldly if there were many users.

    Please Login or Register  to view this content.
    If there was a way I could use worksheets("variable_name_here") then I could cut the loop out.

  7. #7
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Help creating a worload list for undividual people based on data in different sheets.

    If a username were "Fred" for example and the sheet is named Fred

    Sheets("Fred").select

    or

    Please Login or Register  to view this content.
    or again
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    04-11-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Help creating a worload list for undividual people based on data in different sheets.

    Superb, thank you very much.

    I was using the wrong Dim field. Changed to string and used the formula as you pointed out and it worked a charm.

  9. #9
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Help creating a worload list for undividual people based on data in different sheets.

    Good stuff ... glad to hear it

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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