Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Sub Worksheet_Activate()
- End Sub
- Private Sub Worksheet_Change(ByVal Target As Range)
- Dim Oldvalue As String
- Dim Newvalue As String
- 'On Error GoTo Exitsub
- If Target.Column = "5" Then
- If Target.SpecialCells(xlCellTypeAllValidation) Is Nothing Then
- GoTo Exitsub
- Else: If Target.Value = "" Then GoTo Exitsub Else
- Application.EnableEvents = False
- Newvalue = Target.Value
- Application.Undo
- Oldvalue = Target.Value
- If Oldvalue = "" Then
- Target.Value = Newvalue
- Else
- Target.Value = Oldvalue & ", " & Newvalue
- End If
- MsgBox (Target.Value)
- Debug.Print Target.Value
- 'Suzdavane na spisuk s ceni
- Dim dict As Scripting.Dictionary
- Dim total
- Set dict = New Scripting.Dictionary
- total = 0
- 'Populvane na spisuk s ceni
- dict.Add Key:="Чипс", Item:=2.8
- dict.Add Key:="Хляб", Item:=1.4
- dict.Add Key:="Шоколад", Item:=2.4
- dict.Add Key:="Безалкохолни напитки", Item:=1.8
- Dim selectedItems() As String
- selectedItems = Split(Target.Value, ",")
- For Each element In selectedItems
- If dict.Exists(Trim(element)) Then
- total = total + dict.Item(Trim(element))
- End If
- Next element
- Dim PRODUCT_PRICE_COL_NAME
- PRODUCT_PRICE_COL_NAME = "F"
- Dim prodPriceCol
- prodPriceCol = PRODUCT_PRICE_COL_NAME + CStr(Target.Row)
- MsgBox (prodPriceCol)
- Range(prodPriceCol).Value = total
- MsgBox (total)
- End If
- End If
- Application.EnableEvents = True
- Exitsub:
- Application.EnableEvents = True
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement