Hello Everyone!
I'm fairly new to VBA and I'm facing a problem : I have a pre-selection of sheets to save to pdf. However, inside this selection I want to only save the ones that are filled on the cells C8 or D8.
Is this possible to do?
At the moment my code looks like this , it's saving all of the pre-selection but I'm not being able to filter the second part.
Can someone help me out?
Sub Export_As_PDF()
Filename = Application.GetSaveAsFilename( _
fileFilter:="PDF Files (*.pdf), *.pdf")
If TypeName(Filename) = "Boolean" Then
MsgBox "Processo Cancelado."
Exit Sub
Else
CheckName = VBA.FileSystem.Dir(Filename)
If CheckName = VBA.Constants.vbNullString Then
Sheets(Array("Capa", "Condições", "Tarifário_Envios ibéricos", "Tarifário_Envios ibéricos (2)", "Tarifário_Envios internacionais", "Tarifário_Envios carga", "Tarifário_Para Hoje", "Tarifário_Serviços adicionais", "Tarifário_Serviços adiciona (2)", "Tarifário_Serviços adiciona (3)", "Tarifário_Serviços adiciona (4)", "Aprovação")).Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Filename, openafterpublish:=True, ignoreprintareas:=False
ActiveWindow.Zoom = True
MsgBox "Proposta Comercial Exportada para PDF."
Else
answer = MsgBox("The FileName already exists. Do you want to overwrite?", vbQuestion + vbYesNo)
If answer = vbYes Then
Sheets(Array("Capa", "Condições", "Tarifário_Envios ibéricos", "Tarifário_Envios ibéricos (2)", "Tarifário_Envios internacionais", "Tarifário_Envios carga", "Tarifário_Para Hoje", "Tarifário_Serviços adicionais", "Tarifário_Serviços adiciona (2)", "Tarifário_Serviços adiciona (3)", "Tarifário_Serviços adiciona (4)", "Aprovação")).Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Filename, openafterpublish:=True, ignoreprintareas:=False
ActiveWindow.Zoom = True
MsgBox "Proposta Comercial Exportada para PDF."
Else
MsgBox "Proposta Cancelada."
Exit Sub
End If
End If
End If
End Sub
I'm fairly new to VBA and I'm facing a problem : I have a pre-selection of sheets to save to pdf. However, inside this selection I want to only save the ones that are filled on the cells C8 or D8.
Is this possible to do?
At the moment my code looks like this , it's saving all of the pre-selection but I'm not being able to filter the second part.
Can someone help me out?
Sub Export_As_PDF()
Filename = Application.GetSaveAsFilename( _
fileFilter:="PDF Files (*.pdf), *.pdf")
If TypeName(Filename) = "Boolean" Then
MsgBox "Processo Cancelado."
Exit Sub
Else
CheckName = VBA.FileSystem.Dir(Filename)
If CheckName = VBA.Constants.vbNullString Then
Sheets(Array("Capa", "Condições", "Tarifário_Envios ibéricos", "Tarifário_Envios ibéricos (2)", "Tarifário_Envios internacionais", "Tarifário_Envios carga", "Tarifário_Para Hoje", "Tarifário_Serviços adicionais", "Tarifário_Serviços adiciona (2)", "Tarifário_Serviços adiciona (3)", "Tarifário_Serviços adiciona (4)", "Aprovação")).Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Filename, openafterpublish:=True, ignoreprintareas:=False
ActiveWindow.Zoom = True
MsgBox "Proposta Comercial Exportada para PDF."
Else
answer = MsgBox("The FileName already exists. Do you want to overwrite?", vbQuestion + vbYesNo)
If answer = vbYes Then
Sheets(Array("Capa", "Condições", "Tarifário_Envios ibéricos", "Tarifário_Envios ibéricos (2)", "Tarifário_Envios internacionais", "Tarifário_Envios carga", "Tarifário_Para Hoje", "Tarifário_Serviços adicionais", "Tarifário_Serviços adiciona (2)", "Tarifário_Serviços adiciona (3)", "Tarifário_Serviços adiciona (4)", "Aprovação")).Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Filename, openafterpublish:=True, ignoreprintareas:=False
ActiveWindow.Zoom = True
MsgBox "Proposta Comercial Exportada para PDF."
Else
MsgBox "Proposta Cancelada."
Exit Sub
End If
End If
End If
End Sub