Count cells if weekends
Macro Title:
|
Worksheet Variable:
|
Result Variable:
|
Row Reference Variable:
|
Worksheet Name:
|
Column Reference:
enter the column reference from which you want to count if weekends |
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 days of 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 days of a weekend |
Number of last weekday:
enter the cell reference that captures the first day of the weekend (Saturday), consistent with the return type |
Output Cell:
|
First Comment:
' |
Second Comment:
' |
Sub Count_cells_if_weekends()
'declare a variable
Dim ws As Worksheet
Set ws = Worksheets("Analysis")
counter = 0
'count cells if weekends
For x = 8 To 14
If Weekday(ws.Range("B" & x), 2) >= ws.Range("C5") Then
counter = counter + 1
End If
Next x
ws.Range("E8") = counter
End Sub
Sub Count_cells_if_weekends()
'declare a variable
Dim ws As Worksheet
Dim ws As Worksheet
Set ws = Worksheets("Analysis")
counter = 0
'count cells if weekends
For x = 8 To 14
For x = 8 To 14
If Weekday(ws.Range("B" & x), 2) >= ws.Range("C5") Then
counter = counter + 1
End If
Next x
ws.Range("E8") = counter
End Sub