Hi all,
I have written 3 separate macros in a protected workbook which are running successfully, however I have 2 additional functions that I'm unable to get working. I have explained below what my macro does (in a nutshell) to give context to what I need to add in.
3 existing macros I am currently using:
Macro 1 - NextQuote(): Clears existing data and changes quote number to next sequential number (also unprotects and re-protects main workbook);
Macro 2 - SaveQuoteWithNewName(): Creates new macro enabled workbook saved with a specific name (also unprotects and re-protects main workbook);
Macro 3 - SaveFinalQuoteAsPDF(): Creates PDF copy from the new macro enabled workbook, saved in same name as the workbook it was created from.
2 additional fuctions I need to perform, but can't get working:
Note - the new macro enabled workbook will have a different name each time it is saved as it incorporates a quote number and and Customer Name.
Here is my VBA coding that is currently performing my 3 macros. Advice on how I could incorporate my second 2 requirements into this coding would be hugely appreciated!
Thanks in advance!
Lou
I have written 3 separate macros in a protected workbook which are running successfully, however I have 2 additional functions that I'm unable to get working. I have explained below what my macro does (in a nutshell) to give context to what I need to add in.
3 existing macros I am currently using:
Macro 1 - NextQuote(): Clears existing data and changes quote number to next sequential number (also unprotects and re-protects main workbook);
Macro 2 - SaveQuoteWithNewName(): Creates new macro enabled workbook saved with a specific name (also unprotects and re-protects main workbook);
Macro 3 - SaveFinalQuoteAsPDF(): Creates PDF copy from the new macro enabled workbook, saved in same name as the workbook it was created from.
2 additional fuctions I need to perform, but can't get working:
- Protect the data in the new macro enabled workbook that is created by running macro #2;
- Remove Conditional Formatting in the new macro enabled workbook that is created by running macro #2 (but don't remove from the original workbook).
Note - the new macro enabled workbook will have a different name each time it is saved as it incorporates a quote number and and Customer Name.
Here is my VBA coding that is currently performing my 3 macros. Advice on how I could incorporate my second 2 requirements into this coding would be hugely appreciated!

Code:
Sub NextQuote() Worksheets("quoting tool").Unprotect Password:="chcp"
Range("G4").Value = Range("G4").Value + 1
Range("servicetype1:D36,B38:E42,C7:C8,K3:K6,C11:C11").ClearContents
Worksheets("quoting tool").Protect Password:="chcp"
End Sub
Sub SaveQuoteWithNewName()
Worksheets("quoting tool").Unprotect Password:="chcp"
Dim NewFN As Variant
' Copy Quote to a new workbook
Sheets(Array("quoting tool", "nurses", "client contribution", "services", "level 1 and 2", "level 3 and 4", "instructions for use", "pricing list")).Copy
Worksheets("quoting tool").Range("I:Z").EntireColumn.Hidden = True
NewFN = "M:\Always Used\CHCP Quoting Tool\CHCP Customer Quotes\CHCP Quote " & Range("G4").Value & " - " & Range("C3").Value & ".xlsm"
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs NewFN, FileFormat:=xlOpenXMLWorkbookMacroEnabled
Application.DisplayAlerts = True
ActiveWorkbook.Close
Worksheets("quoting tool").Protect Password:="chcp"
ThisWorkbook.Save
ThisWorkbook.Close
End Sub
Sub SaveFinalQuoteAsPDF()
Dim NewFN As Variant
NewFN = "M:\Always Used\CHCP Quoting Tool\CHCP Customer Quotes\CHCP Quote " & Range("G4").Value & " - " & Range("C3").Value & ".pdf"
' Export the invoice sheet as PDF
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=NewFN, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=True
ThisWorkbook.Save
ThisWorkbook.Close
ActiveWorkbook.Save
ActiveWorkbook.Close
End Sub
Thanks in advance!

Lou