Hi,
I hope somebody can help with this problem, had some great help here in the past.
I am trying to make a macro which will progress through a column of data and distribute the contents between several other sheets. The purpose is to allocate appointments between a certain number of people who are available for that particular day.
My main sheet has a list of names and telephone numbers for people who we need to contact. The number of people that the appointments are to be allocated between varies from day to day so I have a cell where I enter this info (name = numPeople), as well as a cell which totals the number of appointment (name = totalEntries). So if there are 100 appointments and 10 people working they should get 10 appointments each. The appointments are ordered by an estimated time, so they should be allocated one at a time between the sheets working down the list. Here is what I have made so far, but it doesn't seem to do anything other than quickly select each cell in turn.
The code is supposed to use 3 counters:![]()
Sub Allocate() Dim mainCounter As Integer Dim sheetCounter As Integer Dim lineCounter As Integer 'tracking position in the main data mainCounter = "1" 'sheetCounter will be a number equal to one of the worksheets sheetCounter = "0" 'lineCounter will track the row where date is actively being pasted (starting at 6 - headers in the first 5 rows) lineCounter = "6" While mainCounter < totalEntries 'select correct worksheet using numPeople If sheetCounter = numPeople Then sheetCounter = "1" lineCounter = lineCounter + 1 Else sheetCounter = sheetCounter + 1 End If Sheets("Data").Cells("A" & mainCounter).Copy Destination:=Sheets("num" & sheetCounter).Range("A" & lineCounter) mainCounter = mainCounter + 1 Wend End Sub
mainCounter to track position in main data (sheet name "Data")
sheetCounter to decide which sheet the data should be pasted to (sheets named "num1", "num2" etc)
lineCounter to decide which row it should pasting onto in each sheet
Any help/pointers as to where I'm going wrong would be appreciated, not having much look with Google.
Regards
Diberlee
Bookmarks