Como guardo la hoja numero 1 como pdf con vba

Me gustaria guardar solo la "hoja instruccion" en pdf de un libro de excel tengo el siguiente código y no se en que parte del código lo inserto para que me lo guarde la ruta seria una carpeta en el escritorio les envio el codigo:

Espero haberme hecho entender gracias y felices fiestas y prospero 2020

Sub CommandButton1_Click()
Dim mensaje As String
mensaje = MsgBox("SE INGRESO EL NUMERO DE LOAD/TRACKING?", vbOKCancel, "CONFIRMACION FLEX COAH")
If mensaje = vbOK Then
'incrementa el consecutivo
ActiveSheet.Range("E3").Value = ActiveSheet.Range("E3").Value + 1
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Application.ScreenUpdating = False
Range("B5"). Copy
Worksheets("Datos guardados"). Range("A6"). PasteSpecial xlPasteValues
Range("B6"). Copy
Worksheets("Datos guardados"). Range("B6"). PasteSpecial xlPasteValues
Range("F5"). Copy
Worksheets("Datos guardados"). Range("C6"). PasteSpecial xlPasteValues
Range("F9"). Copy
Worksheets("Datos guardados"). Range("D6"). PasteSpecial xlPasteValues
Range("F6"). Copy
Worksheets("Datos guardados"). Range("E6"). PasteSpecial xlPasteValues
Range("B13"). Copy
Worksheets("Datos guardados"). Range("H6"). PasteSpecial xlPasteValues
Range("F8"). Copy
Worksheets("Datos guardados"). Range("F6"). PasteSpecial xlPasteValues
Range("C15"). Copy
Worksheets("Datos guardados"). Range("G6"). PasteSpecial xlPasteValues
Range("F13"). Copy
Worksheets("Datos guardados"). Range("I6"). PasteSpecial xlPasteValues
Range("B20"). Copy
Worksheets("Datos guardados"). Range("J6"). PasteSpecial xlPasteValues
Range("F20"). Copy
Worksheets("Datos guardados"). Range("K6"). PasteSpecial xlPasteValues
Range("E3"). Copy
Worksheets("Datos guardados"). Range("L6"). PasteSpecial xlPasteValues
Range("F7"). Copy
Worksheets("Datos guardados"). Range("M6"). PasteSpecial xlPasteValues
 Sheets("Datos guardados").Select
    Rows("6:6").Select
    Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Worksheets("Hoja instruccion"). Range("B5"). ClearContents
Worksheets("Hoja instruccion"). Range("B6"). ClearContents
Worksheets("Hoja instruccion"). Range("F5"). ClearContents
Worksheets("Hoja instruccion"). Range("F6"). ClearContents
Worksheets("Hoja instruccion"). Range("F9"). ClearContents
Worksheets("Hoja instruccion"). Range("B13"). ClearContents
Worksheets("Hoja instruccion"). Range("F13"). ClearContents
Worksheets("Hoja instruccion"). Range("F8"). ClearContents
Worksheets("Hoja instruccion"). Range("C15"). ClearContents
Worksheets("Hoja instruccion"). Range("B20"). ClearContents
Worksheets("Hoja instruccion"). Range("F20"). ClearContents
 End If
End Sub
Respuesta
2

Seria después de copiar los datos y ante de limpiar la hoja instrucción

Este setia el código

Sheets("hoja instruccion").Select 
 'Misma ruta del origen 
Ruta = ThisWorkbook.Path & "\"  
'Nombre de hoja 
nombre = Sheets("hoja instruccion").Range("k5")  
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _ 
Filename:=Ruta & nomb & ".pdf", _ 
Quality:=xlQualityStandard, IncludeDocProperties:=True, _ 
IgnorePrintAreas:=False, OpenAfterPublish:=False

solo cambia la ruta por la que quiere 

Y la celda del nombre por el nobre que le quiere dar

¿Gracias por la respuesta una ultima duda con esta rutina se adaptaría a cualquier pc? ¿Es decir voy a enviar el archivo por correo a varios destinatarios y se tendría que adaptar a cualquier pc seria esto posible con esta rutina?

Saludos

Me funciono muy bien de hecho es lo que buscaba solo me queda la duda arriba mencionada

Si, no tendría problema en usa en otras pc

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas