Needsomehelp10
New Member
- Joined
- Sep 5, 2017
- Messages
- 18
Hey guys,
I am trying to use a If ElseIf to determine where to save a file. For instance if A2 equals A, it will save in one location. If A2 equals B, the file will save in another location. Below is the VBA code I have so far. It will recognize the first if statement but will not carry out the ElseIf condition. Any help would be much appreciated thanks.
Sub
Dim Filename As String
Dim FilePath As String
If Range("A2") = "A" Then
Filename = ActiveSheet.Name & "December"
FilePath = "Insert File Path Here"
ActiveSheet.SaveAs Filename:=FilePath & "" & Filename, FileFormat:=51
ElseIf Range("A2") = "B" Then
Filename = ActiveSheet.Name & "December"
FilePath = "Insert Alternative File Path Here"
ActiveSheet.SaveAs Filename:=FilePath & "" & Filename, FileFormat:=51
EndIf
End Sub
I am trying to use a If ElseIf to determine where to save a file. For instance if A2 equals A, it will save in one location. If A2 equals B, the file will save in another location. Below is the VBA code I have so far. It will recognize the first if statement but will not carry out the ElseIf condition. Any help would be much appreciated thanks.
Sub
Dim Filename As String
Dim FilePath As String
If Range("A2") = "A" Then
Filename = ActiveSheet.Name & "December"
FilePath = "Insert File Path Here"
ActiveSheet.SaveAs Filename:=FilePath & "" & Filename, FileFormat:=51
ElseIf Range("A2") = "B" Then
Filename = ActiveSheet.Name & "December"
FilePath = "Insert Alternative File Path Here"
ActiveSheet.SaveAs Filename:=FilePath & "" & Filename, FileFormat:=51
EndIf
End Sub