Needsomehelp10
New Member
- Joined
- Sep 5, 2017
- Messages
- 18
Hey guys,
I am trying to use an input box to help determine a variable in my vba code. For example, I want an inbox to pop up and ask what month is it (1-12)? If they answer 1, then the month used for the code will be January and so on. Below is the code I have currently. Is what I want to do possible? The variable I want the input box answer to change is the mnth variable. Thanks in advance.
Subfilelocation ()
Dim Filename As String
Dim FilePath As String
Dim Yer As Integer
Dim mnth As String
mnth = "October "
Yer = 2017
If Range("A2") = "A" Then
Filename = ActiveSheet.Name & " TB - " & mnth & Yer
FilePath = "Insert File Path Here"
ActiveSheet.SaveAs Filename:=FilePath & "" & Filename, FileFormat:=51
ElseIf Range("A2") = "B" Then
Filename = ActiveSheet.Name & " TB - " & mnth & Yer
FilePath = "Insert Alternative File Path Here"
ActiveSheet.SaveAs Filename:=FilePath & "" & Filename, FileFormat:=51
End If
End Sub
I am trying to use an input box to help determine a variable in my vba code. For example, I want an inbox to pop up and ask what month is it (1-12)? If they answer 1, then the month used for the code will be January and so on. Below is the code I have currently. Is what I want to do possible? The variable I want the input box answer to change is the mnth variable. Thanks in advance.
Subfilelocation ()
Dim Filename As String
Dim FilePath As String
Dim Yer As Integer
Dim mnth As String
mnth = "October "
Yer = 2017
If Range("A2") = "A" Then
Filename = ActiveSheet.Name & " TB - " & mnth & Yer
FilePath = "Insert File Path Here"
ActiveSheet.SaveAs Filename:=FilePath & "" & Filename, FileFormat:=51
ElseIf Range("A2") = "B" Then
Filename = ActiveSheet.Name & " TB - " & mnth & Yer
FilePath = "Insert Alternative File Path Here"
ActiveSheet.SaveAs Filename:=FilePath & "" & Filename, FileFormat:=51
End If
End Sub