Lux Aeterna
Board Regular
- Joined
- Aug 27, 2015
- Messages
- 201
- Office Version
- 2019
- Platform
- Windows
Hello precious forumers!!
I've got a macro that saves as PDF. Now I'd like to adjust it in order to save to a different folder according to the value of cell F7 on sheet Test pap.
The path I use at the moment is C:\Users\pc50\Desktop\New results\
Thank you in advance!
I've got a macro that saves as PDF. Now I'd like to adjust it in order to save to a different folder according to the value of cell F7 on sheet Test pap.
The path I use at the moment is C:\Users\pc50\Desktop\New results\
Thank you in advance!
VBA Code:
Sub ÁðïèÞêåõóç()
Application.ScreenUpdating = False
Dim ID As Range, sup As String, sID As String
If Sheets("Test pap").Range("U2") = "" Then
MsgBox ("Ôï ID äåí ìðïñåß íá åßíáé êåíü.")
Sheets("Test pap").Range("U2").Select
Exit Sub
End If
If Sheets("Test pap").Range("U3") = "" Then
MsgBox ("Ôï êßôñéíï êåëß äåí ìðïñåß íá åßíáé êåíü.")
Sheets("Test pap").Range("U3").Select
Exit Sub
End If
Set ID = Sheets("List" & Range("Y2").Value).Range("A:A").Find(Sheets("Test pap").Range("U2").Value, LookIn:=xlValues, lookat:=xlWhole)
If Not ID Is Nothing Then
If ID.Offset(, 1) <> "" Then
If MsgBox("Ôï áðïôÝëåóìá Ý÷åé Þäç äïèåß áðü " & ID.Offset(, 37) & "." & Chr(10) _
& "Èåò ïðùóäÞðïôå íá ôï áíôéêáôáóôÞóåéò;", vbYesNo + vbDefaultButton2) = vbYes Then
ID.Offset(, 1) = Sheets("Test pap").Range("AB9")
ID.Offset(, 38) = Sheets("Test pap").Range("A45")
ID.Offset(, 39) = Sheets("Test pap").Range("A46")
Else
Sheets("Test pap").Range("U2:X3").ClearContents
Sheets("Test pap").Range("U2:X2").Select
MsgBox ("Âåâáéþóïõ üôé ôá óôïé÷åßá ðïõ êáôá÷þñçóåò áöïñïýí ôï óùóôü äåßãìá! Áí ü÷é, ðÜôá êáèáñéóìü!")
Exit Sub
End If
Else
ID.Offset(, 1) = Sheets("Test pap").Range("AB9")
ID.Offset(, 38) = Sheets("Test pap").Range("A45")
ID.Offset(, 39) = Sheets("Test pap").Range("A46")
End If
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, FileName:="C:\Users\pc50\Desktop\New results\" & Range("AH1").Value _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
Else
MsgBox ("Ôï ID " & Sheets("Test pap").Range("U2") & " äåí õðÜñ÷åé óôç ëßóôá ôùí ñáíôåâïý " & Sheets("Test pap").Range("Y2") & "." & Chr(10) & "¸ëåãîå üôé Ýâáëåò ôï óùóôü Ýôïò êáé ôï óùóôü ID.")
Sheets("Test pap").Range("U2:X3").ClearContents
Sheets("Test pap").Range("U2:X2").Select
Exit Sub
End If
ActiveWorkbook.Save
Application.ScreenUpdating = True
End Sub