Hi All,
I have the following code that does what I want
However, I have 203 sheets at present and would like to amend this code to function on only the sheets that have a name of "Review of...." Perhaps using a wildcard or >= "Review of". My sheets are Called "Review of 1st Period", "Review of 2nd Period"..... "Review of 39th Period".
How can I change my code to only look at these 39 sheets, rather than all 203 (which will grow). I was thinking that the code of
could be amended to something like
but this doesnt work. I get a "run time error 13 Type Mis-match" at the following line:
Any help would be great as I'm unsure how to make reference to checking the sheet name. Also, if it helps, the sheets are named in VBA as Review_1, Review_2.....Review_39. I don't mind using the sheet names or the reference names, but again, wouldnt know how to code in the name or reference name.
Thanks in advance, Upex.
I have the following code that does what I want
Code:
Sub CompileHistoricEOSScore()
Sheets("HistoricLog").Range("b2:c1000").ClearContents
For Each ws In ActiveWorkbook.Worksheets
If ws.Range("a2").Value = "Review of Performance" Then
For Each c In ws.Range("b40:ay40").cells
CourseTitle = c.Offset(-24, 0).Value
EOSNumber = c.Value
If EOSNumber < 0 Then
GoTo skipit
End If
If CourseTitle = Empty Then
GoTo skipit
End If
Temp = Application.Match(CourseTitle, Sheets("HistoricLog").Range("A1:A100"), 0)
Sheets("HistoricLog").Range("b" & Temp).Value = Sheets("HistoricLog").Range("b" & Temp).Value + EOSNumber
Sheets("HistoricLog").Range("c" & Temp).Value = Sheets("HistoricLog").Range("c" & Temp).Value + 1
skipit:
Next c
End If
Next ws
End Sub
However, I have 203 sheets at present and would like to amend this code to function on only the sheets that have a name of "Review of...." Perhaps using a wildcard or >= "Review of". My sheets are Called "Review of 1st Period", "Review of 2nd Period"..... "Review of 39th Period".
How can I change my code to only look at these 39 sheets, rather than all 203 (which will grow). I was thinking that the code of
Code:
If ws.Range("a2").Value = "Review of Performance" Then
could be amended to something like
Code:
If ws.name >= "Review of" Then
but this doesnt work. I get a "run time error 13 Type Mis-match" at the following line:
Code:
Sheets("HistoricLog").Range("b" & Temp).Value = Sheets("HistoricLog").Range("b" & Temp).Value + EOSNumber
Any help would be great as I'm unsure how to make reference to checking the sheet name. Also, if it helps, the sheets are named in VBA as Review_1, Review_2.....Review_39. I don't mind using the sheet names or the reference names, but again, wouldnt know how to code in the name or reference name.
Thanks in advance, Upex.