All of my macros work, but I'm trying to get them to work more efficiently and make it easier to make any updates that might be needed in the future. I know that other people move calculated variables into their own functions and are able to integrate that into their macro.
If I can get an example of how to do it, I can go about getting the practice of doing this a couple dozen times myself. I've found myself using the same functions over and over again instead of using this other, efficient way other people use.
Here is one snippet that I use a lot to build the beginnings of a dynamic filepath that is in a bunch of macros that should/could be its own function. How do I set it up so that other macros can reference the variables "monabbr", "folnum", and "srchmnth" without having to use the full snippet?
If I can get an example of how to do it, I can go about getting the practice of doing this a couple dozen times myself. I've found myself using the same functions over and over again instead of using this other, efficient way other people use.
Here is one snippet that I use a lot to build the beginnings of a dynamic filepath that is in a bunch of macros that should/could be its own function. How do I set it up so that other macros can reference the variables "monabbr", "folnum", and "srchmnth" without having to use the full snippet?
Code:
SrchMnth = Range("C2").Value
MonAbbr = Left(SrchMnth, 3)
If SrchMnth = "January" Then
FoldNum = "01."
ElseIf SrchMnth = "February" Then
FoldNum = "02."
ElseIf SrchMnth = "March" Then
FoldNum = "03."
ReportQ = 1
ElseIf SrchMnth = "April" Then
FoldNum = "04."
ElseIf SrchMnth = "May" Then
FoldNum = "05."
ElseIf SrchMnth = "June" Then
FoldNum = "06."
ReportQ = 2
ElseIf SrchMnth = "July" Then
FoldNum = "07."
ElseIf SrchMnth = "August" Then
FoldNum = "08."
ElseIf SrchMnth = "September" Then
FoldNum = "09."
ReportQ = 3
ElseIf SrchMnth = "October" Then
FoldNum = "10."
ElseIf SrchMnth = "November" Then
FoldNum = "11."
ElseIf SrchMnth = "December" Then
FoldNum = "12."
ReportQ = 4
Else: MsgBox "Invalid Month. Enter the full month name without any extra characters."
Exit Sub
End If