Hi all,
I don't understand why the below code is not working. I'm Creating a program that formats Pivot Tables based on Fiscal Month. Sheet2 contains a table of FiscalMonth start and end dates. The issue I am having is that my Create_Pivot Subroutine, for some reason, does not "see" the value in FiscalMonth. Below is the part of Create_Pivot () that is giving me the problem. The if FiscalMonth = "September" statement is ignored and the subroutine ends. I'm new to VBA and do not fully understand why it's not working.
Private Sub CommandButton1_Click()
'This Subroutine determines the current Fiscal Month
Dim Today As Date
Dim FiscalMonth As String
Today = Date
If Today > Sheet2.Cells(12, 1) And Today <= Sheet2.Cells(12, 2) Then
FiscalMonth = "September"
Worksheets.Add After:=Worksheets(Worksheets.Count), Count:=1 Create_Pivot
End If
End Sub
--------------
Private Sub Create_Pivot()
If FiscalMonth = "September" Then
--------------
any help is much appreciated.
Thanks
I don't understand why the below code is not working. I'm Creating a program that formats Pivot Tables based on Fiscal Month. Sheet2 contains a table of FiscalMonth start and end dates. The issue I am having is that my Create_Pivot Subroutine, for some reason, does not "see" the value in FiscalMonth. Below is the part of Create_Pivot () that is giving me the problem. The if FiscalMonth = "September" statement is ignored and the subroutine ends. I'm new to VBA and do not fully understand why it's not working.
Private Sub CommandButton1_Click()
'This Subroutine determines the current Fiscal Month
Dim Today As Date
Dim FiscalMonth As String
Today = Date
If Today > Sheet2.Cells(12, 1) And Today <= Sheet2.Cells(12, 2) Then
FiscalMonth = "September"
Worksheets.Add After:=Worksheets(Worksheets.Count), Count:=1 Create_Pivot
End If
End Sub
--------------
Private Sub Create_Pivot()
If FiscalMonth = "September" Then
--------------
any help is much appreciated.
Thanks