Can I please get some help?
When I add items to the order, the TotalRange updates, when I click the IncreaseIcon or DecreaseIcon the TotalRange updates, but when I click the DeleteIcon, the Totals are not updating..
When I add items to the order, the TotalRange updates, when I click the IncreaseIcon or DecreaseIcon the TotalRange updates, but when I click the DeleteIcon, the Totals are not updating..
VBA Code:
Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
With POS
If Not Intersect(Target, Range("L16:Q70")) Is Nothing Then
Range("B7").Value = Target.Row
End If
End With
If Shapes("DeleteIcon").Visible = True Then Shapes("DeleteIcon").Visible = msoFalse
If Target.CountLarge > 1 Then Exit Sub
If Not Intersect(Target, Range("N16:Q70")) Is Nothing And Range("N" & Target.Row).Value <> Empty Then
Range("B7").Value = Target.Row 'Selected Row
Range("B8").Value = Range("M" & Target.Row).Value ' Set Item ID
With Shapes("DeleteIcon")
.Left = Range("R" & Target.Row).Left + 2
.Top = Range("R" & Target.Row).Top + 2
.Visible = msoTrue
End With
End If
If Shapes("IncreaseIcon").Visible = True Then Shapes("IncreaseIcon").Visible = msoFalse
If Target.CountLarge > 1 Then Exit Sub
If Not Intersect(Target, Range("N16:Q70")) Is Nothing And Range("N" & Target.Row).Value <> Empty Then
Range("B7").Value = Target.Row 'Selected Row
Range("B8").Value = Range("M" & Target.Row).Value 'Set Item ID
With Shapes("IncreaseIcon")
.Left = Range("O" & Target.Row).Left + 24
.Top = Range("O" & Target.Row).Top + 2
.Visible = msoTrue
End With
End If
If Shapes("DecreaseIcon").Visible = True Then Shapes("DecreaseIcon").Visible = msoFalse
If Target.CountLarge > 1 Then Exit Sub
If Not Intersect(Target, Range("N16:Q70")) Is Nothing And Range("N" & Target.Row).Value <> Empty Then
Range("B7").Value = Target.Row 'Selected Row
Range("B8").Value = Range("M" & Target.Row).Value ' Set Item ID
With Shapes("DecreaseIcon")
.Left = Range("O" & Target.Row).Left + 2
.Top = Range("O" & Target.Row).Top + 2
.Visible = msoTrue
End With
End If
End Sub
VBA Code:
Option Explicit
Sub DeleteItem()
Dim SelRow As Long, ItemDBRow As Long, LastRow As Long
Dim TotalRange As Range
With POS
SelRow = .Range("B7").Value
LastRow = .Range("L16:Q999").Find(What:="*", After:=.Range("L16"), LookAt:=xlPart, LookIn:=xlValues, SearchOrder:=xlByRows, SearchDirection:=xlPrevious, MatchCase:=False).Row + 1 'First Available Row
If .Range("U" & SelRow).Value <> Empty Then
ItemDBRow = .Range("U" & SelRow).Value
'ORDERITEMS.Range("B" & ItemDBRow & ":H" & ItemDBRow).ClearContents 'Clear All Info But The Order# To Maintain Row
End If
If SelRow = LastRow Then GoTo OnLastRow
.Range("L" & SelRow & ":U" & LastRow - 1).Value = .Range("L" & SelRow + 1 & ":U" & LastRow).Value
.Range("L" & LastRow & ":U" & LastRow).ClearContents 'Clear LastRow
Exit Sub
OnLastRow:
.Range("L" & SelRow & ":U" & SelRow).ClearContents 'Clear Last Row
.Shapes("DeleteIcon").Visible = msoFalse
'.Shapes("IncreaseIcon").Visible = msoFalse
'.Shapes("DecreaseIcon").Visible = msoFalse
End With
End Sub
VBA Code:
Sub Item_AddToOrder()
Dim SelRow As Long, ItemDBRow As Long
Dim ItemName As String, ItemID As String, ItemType As String
Dim FoundItem As Range, TotalRange As Range
With POS
.Range("B8").Value = Application.Caller
ItemDBRow = .Range("B9").Value 'Item DB Row
ItemID = ITEMS.Range("A" & ItemDBRow).Value 'ItemID
ItemType = ITEMS.Range("B" & ItemDBRow).Value 'Item Type
ItemName = ITEMS.Range("C" & ItemDBRow).Value 'Item Name
'Clear any totals temporarily if they exist on saved orders
Set TotalRange = Range("U16:U70").Find("T")
If Not TotalRange Is Nothing Then .Range("P" & TotalRange.Row & ":U" & TotalRange.Row + 5).ClearContents 'Clear Totals
'Check for existing Item & Add Qty, otherwise Add Item
Set FoundItem = .Range("N16:N999").Find(ItemName)
If FoundItem Is Nothing Then 'Not Found
If .Range("N16").Value <> Empty Then
SelRow = .Range("N16:Q70").Find(What:="*", After:=Range("N16"), LookAt:=xlPart, LookIn:=xlValues, SearchOrder:=xlByRows, SearchDirection:=xlPrevious, MatchCase:=False).Row + 1
Else:
SelRow = 16
End If
.Range("B7").Value = SelRow 'Set Selected Row
.Range("L" & SelRow).Value = ItemType 'Item Type
.Range("M" & SelRow).Value = ItemID 'Item ID
.Range("N" & SelRow).Value = ItemName 'Item Name
.Range("O" & SelRow).Value = 1 'Quantity
.Range("P" & SelRow).Value = ITEMS.Range("D" & ItemDBRow).Value 'Item Price
.Range("Q" & SelRow).Value = "=O" & SelRow & "*P" & SelRow 'Total Formula
Else 'Found
SelRow = FoundItem.Row 'Selected Item Row
.Range("O" & SelRow).Value = .Range("O" & SelRow).Value + 1 'Increase Quantity by 1
End If
.Shapes("DeleteIcon").Visible = msoFalse
.Shapes("IncreaseIcon").Visible = msoFalse
.Shapes("DecreaseIcon").Visible = msoFalse
'Add In TotalRange
Order_AddTotals 'Macro To Add Totals In
LastRow = .Range("N999").End(xlUp).Row 'Last Row
'ORDERS.Range("E" & OrderRow).Value = .Range("Q" & LastRow + 1).Value 'Total
'ORDERS.Range("F" & OrderRow).Value = .Range("Q" & LastRow + 2).Value 'Payment
End With
End Sub
Sub Order_AddTotals()
Dim LastRow As Long
With POS
LastRow = .Range("P16:Q999").Find(What:="*", After:=.Range("P16"), LookAt:=xlPart, LookIn:=xlValues, SearchOrder:=xlByRows, SearchDirection:=xlPrevious, MatchCase:=False).Row + 1 'First Avail Row
.Range("P" & LastRow + 1 & ":U" & LastRow + 3).Value = .Range("TotalRange").Value
.Range("Q" & LastRow + 1).Formula = "=Sum(Q16:Q" & LastRow & ")" 'Total
.Range("B14").Value = .Range("Q" & LastRow + 1) 'Add Total to B14
End With
End Sub