SOLVED

Excel VBA macro code

Copper Contributor

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

3 Replies
best response confirmed by Hans Vogelaar (MVP)
Solution

@Tommee 

 

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

or

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

 

@Tommee 

 

Sorry, overlooked the second example.  Try:

 

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

@Joe User 

Thank you Joe.

1 best response

Accepted Solutions
best response confirmed by Hans Vogelaar (MVP)
Solution

@Tommee 

 

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

or

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

 

View solution in original post