VBA to save in PDF the Excel spreadsheet with the name of two Cells

Asked

Viewed 102 times

-1

The spreadsheet I save in pdf with this code:

Sub Salvar_PDF()

'Antes de executar o código é importante definir a áreade impressão

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:="C:\Users\c098150\HUDSON\GEGRO\FORMS\Customização N.º .pdf", OpenAfterPublish:=True

End Sub

I want to add the number that is in cell S7 and the name that is on D13

1 answer

0

From what I understand, you want the values in cells S7 and D13 to be present in the PDF name to be created.

To do this, just concatenate, using "&", the statement "Range('Cell address'). value" in the code, like this:

Sub Salvar_PDF()

'Antes de executar o código é importante definir a áreade impressão

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:="C:\Users\c098150\HUDSON\GEGRO\FORMS\Customização " & Range("S7").Value & " N.º " & Range("D13").Value & ".pdf", OpenAfterPublish:=True

End Sub

Browser other questions tagged

You are not signed in. Login or sign up in order to post.