The value obtained in the first sub does not carry onto the next, how do I go about doing so?
This is just a small part of the codes, there are many other variables and other user inputs that do not allow me to combine the subs.
Private Sub lbEY_AfterUpdate()
Dim sd As Date
Dim ed As Date
Dim fromd As String
Dim tod As String
sm = Month(DateValue("01-" & lbSM & "-1900"))
em = Month(DateValue("01-" & lbEM & "-1900"))
sd = DateSerial(lbSY, sm, 1)
ed = DateSerial(lbEY, em, 1)
fromd = Format(sd, "mmmm yyyy")
tod = Format(ed, "mmmm yyyy")
End Sub
Private Sub CommandButton2_Click()
Range("A1").Value = "For dates " & fromd & " to " & tod & ":"
'This prints out "For dates to :"
End Sub
e.g. fromd is January 2019 and tod is March 2019. The ideal outcome would be for the value in Range A1 to be" For dates January 2019 to March 2019:" Thanks in advance!