Count cells by weekends
Macro Title:
|
Worksheet Variable:
|
Result Variable:
|
Row Reference Variable:
|
Worksheet Name:
|
Column Reference:
enter the column reference from which you want to count by days from the weekend |
First Row Reference:
enter the first row reference which represents the first row of the range from which you want to count the number of cells that contain a weekend |
Last Row Reference:
enter the last row reference which represents the last row of the range from which you want to count the number of cells that contain a weekend |
Number of the weekend days to count for:
enter the cell reference that captures the number of the weekend days |
Output Cell:
|
First Comment:
' |
Second Comment:
' |
Sub Count_cells_by_weekends()
'declare a variable
Dim ws As Worksheet
Set ws = Worksheets("Analysis")
counter = 0
'count cells with the date that falls on a Saturday
For x = 5 To 11
If Weekday(ws.Range("B" & x), 2) = ws.Range("C14") Then
counter = counter + 1
End If
Next x
ws.Range("D14") = counter
End Sub
Sub Count_cells_by_weekends()
'declare a variable
Dim ws As Worksheet
Dim ws As Worksheet
Set ws = Worksheets("Analysis")
counter = 0
'count cells with the date that falls on a Saturday
For x = 5 To 11
For x = 5 To 11
If Weekday(ws.Range("B" & x), 2) = ws.Range("C14") Then
counter = counter + 1
End If
Next x
ws.Range("D14") = counter
End Sub