KlausW
Active Member
- Joined
- Sep 9, 2020
- Messages
- 453
- Office Version
- 2016
- Platform
- Windows
Hi Excel helpers.
I use this VBA code to register who eats when, I have tried to change it so I can use it to register what I would like to buy I my sheets whit some item, but I run into problems and cannot solve them myself. Someone who can help.
All help will be appreciated.
Regards Klaus W
I use this VBA code to register who eats when, I have tried to change it so I can use it to register what I would like to buy I my sheets whit some item, but I run into problems and cannot solve them myself. Someone who can help.
All help will be appreciated.
Regards Klaus W
VBA Code:
Sub Prisliste_Rektangelafrundedehjørner4_Klik()
'If Target.Cells.Count = 1 Then Exit Sub
'If Intersect(Target, Range("A8")) Is Nothing Then Exit Sub
Dim WkRng, DestRng, SrcRng As Range
Dim TidCol, TidRow, c As Integer
With Sheets("Prisliste")
Set WkRng = .Range("A9:A4000") 'Item No.
Set DestRng = .Range("c9:c4000") 'Quantity
On Error GoTo Ooops 'Error handler
TidCol = Application.Match(.Range("A9:A4000"), Sheets("Prisliste").Range("P9:P4000"), 0)
TidRow = Application.Match(.Range("C9:C4000"), Sheets("Prisliste").Range("R9:R4000"), 0)
End With
Application.EnableEvents = False 'Stop this change event code triggereing itself and looping forever
WkRng.Value = Sheets("Prisliste").Cells(TidRow, 3).Resize(7, 1).Value
For c = 0 To 2
Set SrcRng = Sheets("Prisliste").Cells(TidRow, TidCol).Offset(0, c).Resize(7, 1)
DestRng.Offset(0, 2 * c).Value = SrcRng.Value
Next c
Ooops: 'Error message if there is error.
On Error GoTo 0 'set error handling back to default
Application.EnableEvents = True 're-enable events handling
End Sub