Hi there (very new to VBA)
When I run the module Save_Order it runs fine but when I add it to the module Next_Order, it gives me a Compile Error..
What am I doing wrong please?
When I run the module Save_Order it runs fine but when I add it to the module Next_Order, it gives me a Compile Error..
What am I doing wrong please?
VBA Code:
Option Explicit
Public Sub Save_Order()
Dim LastRow As Long, OrderRow As Long, ItemRow As Long, ItemDBRow As Long, TotalRow As Long
Dim TotalRange As Range
With POS
If .Range("M16").Value = Empty Then
MsgBox "Please add at least one item to save this order"
Exit Sub
End If
'Clear Total Rows if Existing (Temporarily)
Set TotalRange = .Range("T16:T999").Find("T")
If Not TotalRange Is Nothing Then .Range("O" & TotalRange.Row & ":T" & TotalRange.Row + 4).ClearContents
LastRow = .Range("M16:P70").Find(What:="*", After:=.Range("M16"), Lookat:=xlPart, LookIn:=xlValues, SearchOrder:=xlByRows, SearchDirection:=xlPrevious, MatchCase:=False).Row + 1 'First Avail Row
If .Range("B3").Value = Empty Then 'New Order
OrderRow = ORDERS.Range("A9999").End(xlUp).Row + 1 'First Available Row
ORDERS.Range("A" & OrderRow).Value = .Range("O13").Value 'New Order Number
Else: 'Existing Order
OrderRow = Range("B3").Value 'Order Row
End If
ORDERS.Range("B" & OrderRow).Value = Now 'Date
ORDERS.Range("C" & OrderRow).Value = .Range("O11").Value 'Register
.Range("O12").Value = Now 'Current Date/Time
'Add In TotalRange
Order_AddTotals 'Macro To Add Totals In
LastRow = .Range("M999").End(xlUp).Row 'Last Row
ORDERS.Range("D" & OrderRow).Value = .Range("P" & LastRow + 3).Value 'Total
ORDERS.Range("E" & OrderRow).Value = .Range("P" & LastRow + 4).Value 'Payment
.Shapes("DeleteIcon").Visible = msoFalse
End With
End Sub
VBA Code:
Option Explicit
Public Sub Next_Order()
With POS
If .Range("M16").Value <> Empty Then Save_Order 'Save Existing Order
.Range("B2").Value = .Range("B4").Value 'Set Next Order ID
.Range("B7,B8,B12,B13,O12,P12,O13,L16:T999").ClearContents
.Shapes("DeleteIcon").Visible = msoFalse
.Range("O13").Value = .Range("B2").Value
.Range("O12").Value = Date 'Set Current Time & Date
.Range("P12").Value = Time 'Set Current Time & Date
End With
End Sub