Hey, I'm new to VBA and this forum and wanted to ask for help.
I have two worksheets; "Report" and "Total".
The goal is to save the values of my table in my "Total" sheet based on the calendar week in cell "S8" as well as 'load' the data as soon as I select the calendar week in cell "S8"
Hopefully there is someone who can adjust my code, so it's not flashing every time I change a value.
Thanks in advance!
I have two worksheets; "Report" and "Total".
The goal is to save the values of my table in my "Total" sheet based on the calendar week in cell "S8" as well as 'load' the data as soon as I select the calendar week in cell "S8"
Hopefully there is someone who can adjust my code, so it's not flashing every time I change a value.
Thanks in advance!
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("C2:D8")) Is Nothing Then
Range("C4:D4").Copy
CW = Sheets("Report").Range("S8")
Sheets("Total").Select
Sheets("Total").Range("1:1").Select
Selection.Find(What:=CW, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.Offset(0, 1).Select
ActiveCell.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Sheets("Report").Select
End If
If Not Intersect(Target, Range("S8")) Is Nothing Then
CW = Sheets("Report").Range("S8")
Sheets("Total").Select
Sheets("Total").Range("1:1").Select
Selection.Find(What:=CW, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.Offset(, 1).Resize(1, 2).Copy
Sheets("Report").Select
Sheets("Report").Range("C2:D8").PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
End If
End Sub