Hi everyone,
I have a workbook with the below code. Everything works fine thanks to @rlv01 .
Next I would like to have the estimate number increase +1 every time the macro is run. I've added code for this but not sure where to add it in the order. Estimate number is in "F4" - Sheet "Estimate"
I would also like to transfer main info from the estimate to a database (sheet "Estimate database")
Data to be transferred:
CELL:
Date F3
Estimate number F4
Client A14
Total G44
Thanks
I have a workbook with the below code. Everything works fine thanks to @rlv01 .
Next I would like to have the estimate number increase +1 every time the macro is run. I've added code for this but not sure where to add it in the order. Estimate number is in "F4" - Sheet "Estimate"
I would also like to transfer main info from the estimate to a database (sheet "Estimate database")
Data to be transferred:
CELL:
Date F3
Estimate number F4
Client A14
Total G44
VBA Code:
Private Sub CommandButton1_Click()
Dim saveLocation As String
Dim rng As Range
saveLocation = "C:\Users\***\Estimates\" & Range("f4").Value & Range("a14").Value & ".pdf"
Set rng = Worksheets("Estimate").Range("A1:g50")
rng.ExportAsFixedFormat Type:=xlTypePDF, Filename:=saveLocation
Worksheets("Estimate").Range("A23:a41").ClearContents
Call saveSheetWithoutFormulas
End Sub
Sub saveSheetWithoutFormulas()
Dim saveLocation As String, xlsxFile As String
Dim WB As Workbook, WS As Worksheet
Dim SheetName As String
SheetName = ActiveSheet.Name
saveLocation = "C:\Users\***\Estimates\" & ActiveSheet.Range("f4").Value & Range("a14").Value
xlsxFile = Split(saveLocation, ".")(0) & ".xlsx"
Application.DisplayAlerts = False
ThisWorkbook.SaveCopyAs Filename:=saveLocation
Set WB = Application.Workbooks.Open(Filename:=saveLocation)
Set WS = WB.Worksheets(SheetName)
WS.UsedRange.Value = WS.UsedRange.Value
WB.saveas Filename:=xlsxFile, FileFormat:=xlOpenXMLWorkbook 'see XlFileFormat Enumeration for different formats
WB.Close False
Application.DisplayAlerts = False
Kill saveLocation
End Sub
Sub NextInvoice()
Range("f4").Value = Range("f4").Value + 1
End Sub
Thanks