I'm trying to make sort of a shopping cart. The goods are on a sheet called List and start from row 2 to row 594. There is a cell besides each item (range "E2:E594"). When I double click the cell, it transfers the data in the cells to the left to another worksheet called Cart and displays a message. The code below is what I cobbled together.
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Intersect(Target, Range("E2:E594")) Is Nothing Then Exit Sub
Sheets("Cart").Range("D34") = Cells(Target.Row, 5)
Sheets("Cart").Range("C34") = Cells(Target.Row, 4)
If Target.Locked Then
Range("A1").Activate
MsgBox "Item added to Cart successfully", vbInformation, "Cart updated"
End If
End Sub
This code works but only for the first row of the Cart worksheet (row 34). If I then go back to the List worksheet and "add" another item by clicking another row, that new selection overrides the information in row 34 of the Cart worksheet. I'd like to have the info from the second item inserted to the 35th row in cells C35 and D35. Can anyone help?
TIA
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Intersect(Target, Range("E2:E594")) Is Nothing Then Exit Sub
Sheets("Cart").Range("D34") = Cells(Target.Row, 5)
Sheets("Cart").Range("C34") = Cells(Target.Row, 4)
If Target.Locked Then
Range("A1").Activate
MsgBox "Item added to Cart successfully", vbInformation, "Cart updated"
End If
End Sub
This code works but only for the first row of the Cart worksheet (row 34). If I then go back to the List worksheet and "add" another item by clicking another row, that new selection overrides the information in row 34 of the Cart worksheet. I'd like to have the info from the second item inserted to the 35th row in cells C35 and D35. Can anyone help?
TIA