Forum Discussion
Excel VBA macro code
Hello. I am trying to test the current or todays date's month and day.
If it matches Dec 31 or Jan 1 or Jan 2, perform EOY or new year processing.
If 12/31 or 1/01 or 1/02 I would like to set the page number to "1" else add 1 to the page number. My page number is located in cell L1 on my excel sheet.
Thank you to all who can help me.
Here is what I have tried to code:
' Comment: Page number is located in cell L1
If (Month(TODAY()) = 12 And Day(TODAY()) = 31) Or _
(Month(TODAY()) = 01 And Day(TODAY()) = 01) Or _
(Month(TODAY()) = 01 And Day(TODAY()) = 02) Then
Range("L1").Value = 01
ElseIf Range("L1").Value > 0 Then
Range("L1").Value = Range("L1").Value + 01
Else
Range("L1").Value = 01
End If
Range("O" & Cmbcellrow).Value = Range("O" & Intcellrow).Value
or
Cells(Cmbcellrow, "o").Value = Cells(Intcellrow, "o").Value
3 Replies
- JoeUser2004Bronze Contributor
Sorry, overlooked the second example. Try:
WorksheetFunction.CountIf(Pg1range, Cells(Intcellrow, "o"))
- TommeeCopper Contributor
Thank you Joe.
- JoeUser2004Bronze Contributor
Range("O" & Cmbcellrow).Value = Range("O" & Intcellrow).Value
or
Cells(Cmbcellrow, "o").Value = Cells(Intcellrow, "o").Value