Hi,
I have a large workbook comprised of sheets dedicated to a specific product. Each product sheet has a list of dates.
I’m trying to create a macro that would tally the number of date entries corresponding to the month and year of todays date. So if today is “13 June 2019” the macro should tally the number of date entries in the month of June 2019.
This_day = Sheet11.Range("Q2").Value references a cell with the “=TODAY()” formula.
I get a run time error 13 “Type mismatch” when I run the code. I’m also not sure if
If Month(k) And Year(k) is the correct way to pull out the month and year corresponding to “TODAY”.
Any help is very much appreciated!
Sub LotsClosedThisMonth()
Dim Last_Row As Variant
Dim k As Variant
Dim j As Variant
Dim This_day As Long
This_day = Sheet11.Range("Q2").Value
Last_Row = Sheet1.Range("O8", Sheet1.Range("O" & Rows.Count).End(xlUp)).Value
j = 0
Sheet11.Range("C3").Value = j
End Sub
I have a large workbook comprised of sheets dedicated to a specific product. Each product sheet has a list of dates.
I’m trying to create a macro that would tally the number of date entries corresponding to the month and year of todays date. So if today is “13 June 2019” the macro should tally the number of date entries in the month of June 2019.
This_day = Sheet11.Range("Q2").Value references a cell with the “=TODAY()” formula.
I get a run time error 13 “Type mismatch” when I run the code. I’m also not sure if
If Month(k) And Year(k) is the correct way to pull out the month and year corresponding to “TODAY”.
Any help is very much appreciated!
Sub LotsClosedThisMonth()
Dim Last_Row As Variant
Dim k As Variant
Dim j As Variant
Dim This_day As Long
This_day = Sheet11.Range("Q2").Value
Last_Row = Sheet1.Range("O8", Sheet1.Range("O" & Rows.Count).End(xlUp)).Value
j = 0
For k = 2 To Last_Row
If Month(k) And Year(k) = This_day Then j = j + 1
Next k
Sheet11.Range("C3").Value = j
End Sub