Forum Discussion

Tommee's avatar
Tommee
Copper Contributor
Aug 01, 2022
Solved

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

  • Tommee 

     

    Range("O" & Cmbcellrow).Value = Range("O" & Intcellrow).Value

    or

    Cells(Cmbcellrow, "o").Value = Cells(Intcellrow, "o").Value

     

3 Replies

  • JoeUser2004's avatar
    JoeUser2004
    Bronze Contributor

    Tommee 

     

    Sorry, overlooked the second example.  Try:

     

    WorksheetFunction.CountIf(Pg1range, Cells(Intcellrow, "o"))

  • JoeUser2004's avatar
    JoeUser2004
    Bronze Contributor

    Tommee 

     

    Range("O" & Cmbcellrow).Value = Range("O" & Intcellrow).Value

    or

    Cells(Cmbcellrow, "o").Value = Cells(Intcellrow, "o").Value

     

Resources