View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Roger Govier[_3_] Roger Govier[_3_] is offline
external usenet poster
 
Posts: 2,480
Default looping down 1 column then start agian at the top of the next column?

Hi Matt

Is this what you mean?
I am assuming that you have a list of differing sheets, which you would set
in myArray
This list would be processed in turn, and their results placed in successive
columns on your tally sheet.
Rather than looping through each item in the column, I have used Countif to
return the number of "BM"

Sub CountData()
Dim source As Worksheet, tally As Worksheet
Dim myArray, myRng As Range
Dim i As Long, j As Long
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
myArray = Array("Staff Monday", _
"Staff Tuesday", "Staff Wednesday")
Set tally = ThisWorkbook.Sheets("TallyDump")
j = 2
For Each source In myArray
For i = 3 To 146
myArray = source.Range(Cells(2, 7), _
Cells(1000, 7)).Offset(0, i)
tally.Cells(i, j) = WorksheetFunction. _
CountIf(myRng, "PM")
Next i
j = j + 1
Next
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub

--
Regards
Roger Govier

"MJKelly" wrote in message
...
Hi Roger,

Worked a treat! Thanks!
I want to make better use of this code so I can use it for multiple
worksheets. I usually do this by moving the code to a new routine and
passing variables from another routine. Is there a way I can do this
within one routine?

Kind regards and thanks again,
Matt