![]() |
Counting times a value occurs
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 |
Counting times a value occurs
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").Are as shifts = shift + application.countif(ar,employee) Next ActiveSheet.Cells(EmployeeRow, 16).Value = shifts * 8 Loop -- Regards, Tom Ogilvy "Jordan" wrote in message ... 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 |
All times are GMT +1. The time now is 02:39 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com