Hello,
I am trying to save the user-inputted value of a TextBox in a variable that I can reference in my Module code. I have stepped through the code and the variable has a value within the Userform code, but it reverts back to zero once I get to the Module code. I have unsuccessfully tried declaring the variable as global in both the Userform and Module. The variable in question is "PeriodStart."
Here is my Userform code:
Here is part of my Module code:
Thanks for your response in advance!
Steve
I am trying to save the user-inputted value of a TextBox in a variable that I can reference in my Module code. I have stepped through the code and the variable has a value within the Userform code, but it reverts back to zero once I get to the Module code. I have unsuccessfully tried declaring the variable as global in both the Userform and Module. The variable in question is "PeriodStart."
Here is my Userform code:
Code:
Public PeriodStart As Date
Private Sub Cancel_Click()
Unload Me
End Sub
Private Sub DateInput_Change()
End Sub
Private Sub OK_Click()
PeriodStart = DateSelect.DateInput.Value
Me.Hide
End Sub
Private Sub Label1_Click()
End Sub
Private Sub UserForm_Click()
End Sub
Code:
Sub CheckDate()
'Macro checks to see if a payment was made in the week period
Dim FirstRow As Integer
Dim LastRow As Integer
Dim PeriodEnd As Date
Dim PaymentDate As Integer
Dim PeriodStartDay As Integer
Dim PeriodEndDay As Integer
Dim PeriodDifference As Integer
DateSelect.Show
PeriodEnd = PeriodStart + 6
PeriodStartDay = Day(PeriodStart)
PeriodEndDay = Day(PeriodEnd)
'Variable used to check if the period stretches over 2 months
PeriodDifference = PeriodEndDay - PeriodStartDay
End Sub
Steve