Counting times a value occurs

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm sure I'm an idiot but I can't get this to work. I need to have the code
count the number of times a name occurs in a given selection. The code below
should give you an idea of what im working on, column 15 is a list of
employees and if the month its calculating is may then the range below is the
range inwhich the employee could be scheduled in may.

If UserForm1.calcMay.Value = True Then
EmployeeRow = 2
Do Until ActiveSheet.Cells((EmployeeRow + 1), 15).Value = Empty
EmployeeRow = EmployeeRow + 1
employee = ActiveSheet.Cells(EmployeeRow, 15).Value
shifts = Range("A4:N8,A10:N14,A16:N20,A22:N26,A28:F32").
Count(employee)
ActiveSheet.Cells(EmployeeRow, 16).Value = shifts * 8

Loop

Thanks for the help,
jordan
 
If UserForm1.calcMay.Value = True Then
EmployeeRow = 2
Do Until ActiveSheet.Cells((EmployeeRow + 1), 15).Value = Empty
EmployeeRow = EmployeeRow + 1
employee = ActiveSheet.Cells(EmployeeRow, 15).Value
for each ar in Range("A4:N8,A10:N14,A16:N20,A22:N26,A28:F32").Areas
shifts = shift + application.countif(ar,employee)
Next
ActiveSheet.Cells(EmployeeRow, 16).Value = shifts * 8
Loop
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top