VBA Staffing advice?

AndrewNSD

New Member
Joined
Aug 30, 2015
Messages
2
Hello!

I am having trouble with VBA and getting it to work with the formula I made. I am using it to find data on another sheet by going down a column and finding anyone with a "D" in the row then pulling the first column name and pasting it on another sheet. This is used for staffing and since we have many people it runs well. I would like to improve the Macro since I am going about it in a very different way than how VBA is supposed to be used.

I am having a button macro past my formula into the cells I want it to on another sheet, and then I drag and drop staff into the sheet I have for printing. This is a very roundabout way, but it seems to work for now. I would like to turn that into all VBA the right way. Keep in mind that this is only a small sample of it. I have each sheet for the week that has its own code, and we run on 4 weeks per a schedule. We are always moving people around on this sheet and so it’s hard to have the names just pasted into the printing sheet.

Below is a small mockup of how it would grab the data. I can't figure out how to make the Macro run off a date on the Printing sheet so I ended up with just a bunch of codes per each sheet. *These are not real names of staff*

any information on how to improve this or different ways to make it better would be greatly appreciated. If any of you could somehow point me in the direction of how to get the macro to also know what unit the staff would be working on by the Cell fill color that would be amazing also

for the sheet I made below, we also have the insides of the cells with the letters colored. Each color represents where they are working. I.e. Green means one unit and orange means another and red means they go where the hole is.


any information on how to improve this or different ways to make it better would be greatly appreciated. If any of you could somehow point me in the direction of how to get the macro to also know what unit the staff would be working on by the Cell fill color that would be amazing also

-Key-
D = Days
E = Evenings
N = Nights


This is the Code Specific to Monday print sheet only

Code:
Sub Monday()
Range("K5:K28").Formula = "=IF(ROWS(K$5:K5)>COUNTIF(‘Master’!$D$3:$D$9,""D""),"""",INDEX(‘Master’!$A$3:$A$9,AGGREGATE(15,6,(ROW(‘Master’!$D$3:$D$9)-ROW(‘Master’!$D$3)+1)/( ‘Master’!$D$3:$D$9=""D""),ROWS(K$5:K5))))"
'Values only
Range("J1:Q48").Value = Range("J1:Q48").Value
End Sub
8/9
8/10
8/11
8/12
8/13
8/14
8/15
8/16
8/17
8/18
8/19
8/20
8/21
8/22
NAME
FTE
Sunday
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Crew, Joe
1.0
D
D
E
E
E
x
x
x
E
E
x
D
D
D
Dhal, Jane
.8
N
N
N
N
x
x
x
x
N
N
x
x
N
N
Doe, John
.6
D
D
x
x
x
x
x
x
D
D
x
x
E
E
Fredrick, Rick
.7
x
x
D
D
D
N
N
N
N
x
x
x
x
x
Harwell, Phill
.9
x
D
D
D
D
x
x
x
E
E
E
E
E
x
Jackson, Andrew
1.0
N
N
N
x
x
N
N
N
N
x
x
N
N
N
Olson, Erik
1.0
E
E
E
x
x
x
E
E
E
E
E
x
E
E

<tbody>
</tbody>
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top