Sub Compute_Order()
Dim ws As Worksheet
Dim rng As Range
Dim cellcount As Range
Dim destcell As Range
Dim i As Integer
Dim rownum As Integer
Dim itemcount As Integer
Dim csum As Range
rownum = 7
itemcount = 1
Set ws = ActiveSheet
Set rng = ws.Range("d7:d106")
For Each cellcount In rng
If cellcount.Value > 0 Then
Set destcell = ws.Cells(rownum, "L")
destcell.Value = itemcount
Set destcell = ws.Cells(rownum, "M")
destcell.Value = ws.Cells(cellcount.Row, "B").Value
Set destcell = ws.Cells(rownum, "N")
destcell.Value = ws.Cells(cellcount.Row, "C").Value
Set destcell = ws.Cells(rownum, "O")
destcell.Value = ws.Cells(cellcount.Row, "D").Value
Set destcell = ws.Cells(rownum, "P")
destcell.Value = ws.Cells(cellcount.Row, "E").Value
Set destcell = ws.Cells(rownum, "Q")
destcell.Value = ws.Cells(rownum, "o").Value * ws.Cells(rownum, "p").Value
rownum = rownum + 1
itemcount = itemcount + 1
End If
Next cellcount
Set destcell = Range("p7").End(xlDown).Offset(1, 0)
destcell.Value = "Sub total"
Set rng = Range("q7:q" & Range("q7").End(xlDown).Row)
Set csum = Range("q7").End(xlDown).Offset(1, 0)
csum.Formula = "=SUM(" & rng.Address(False, False) & ")"
Set destcell = Range("p7").End(xlDown).Offset(1, 0)
destcell.Value = "Tax 12%"
Set csum = Range("q7").End(xlDown).Offset(1, 0)
csum.Formula = csum.Offset(-1, 0).Value * 0.12
Set destcell = Range("p7").End(xlDown).Offset(1, 0)
destcell.Value = "Grand Total"
Set csum = Range("q7").End(xlDown).Offset(1, 0)
csum.Formula = csum.Offset(-2, 0).Value + csum.Offset(-1, 0).Value
End Sub
Sub clearorder()
Dim ws As Worksheet
Dim rng As Range
Set ws = ActiveSheet
Set rng = ws.Range("d7:d106")
rng.Value = 0
Set rng = ws.Range("l7:q" & Range("q7").End(xlDown).Row)
rng.Value = " "
End Sub
Sub copyrowsofqtyisgreaterthanzero()
Dim ws As Worksheet
Dim qtyrange As Range
Dim cell As Range
Dim destcell As Range
Dim rownum As Integer
Set ws = ActiveSheet
Set qtyrange = ws.Range("d7:d10")
rownum = 7
For Each cell In qtyrange
If IsNumeric(cell.Value) And cell.Value > 0 Then
Set destcell = ws.Cells(rownum, "L")
ws.Rows(cell.Row).Copy Destination:=destcell
rownum = rownum + 1
End If
Next cell
End Sub
Sub SaveSelectionAsPDF()
Dim Filepath As String
Dim FileName As String
Dim FullPath As String
Dim CurrentDateTime As String
Dim SelectionRange As Range
Range("L2:Q" & Range("q7").End(xlDown).Row).Select
' Set the selected range
Set SelectionRange = Selection
'Set the desired file path (change this to your preferred directory)
Filepath = "C:\Users\Kaith Lhorisse\OneDrive\Documents\Desktop\AIS GALVEZ\"
'Get the current and time
CurrentDateTime = Format(Now, "yyyy-mm-dd_hh-mm-ss")
'Create the file name
FileName = "receipt_" & CurrentDateTime & ".pdf"
'combine the path and file name
FullPath = Filepath & FileName
'Save the swelected range as pdf
SelectionRange.ExportAsFixedFormat Type:=xlTypePDF, FileName:=FullPath, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
'Inform the user
MsgBox "Receipt saved to " & FullPath
End Sub