Forum Discussion
Update data when new data is entered in a rage of cells
rwagner34 This can be done using a macro:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim dashUpdate As Range
Set dashUpdate = ThisWorkbook.Sheets("Dashboard sheet").Range("5:5")
If Intersect(Target, Range("G:G")) Is Nothing Then
Else
Target.EntireRow.Copy dashUpdate
End If
End SubThis macro must be on the sheet object where the data will be updated
"Dashboard sheet" needs to be the name of the sheet where the row will be copied to
and change "5:5" to the row where you want that row copied to
and change "G:G" to the column that matches the column with dollars that if updated you want copied.
- rwagner34Mar 16, 2021Copper Contributor
Thank you!
I am getting an error from the first line - below. I did update the other data, should "Worksheet_Change" be something else? Under the screen shot is the Marco.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim dashUpdate As Range
Set dashUpdate = ThisWorkbook.Sheets("Dashboard").Range("$A$6")
If Intersect(Target, Range("$B$4:$B$101")) Is Nothing Then
Else
Target.EntireRow.Copy dashUpdate
End IfEnd Sub
- mtarlerMar 16, 2021Silver Contributor
rwagner34 so in the VBA editor you need to open the code page for the specific Sheet. And then in that window select Worksheet from the left drop down and the right will likely auto populate with SelectionChange but otherwise select that:
If you pasted that Sub into workbook or a module or something, yeah it won't understand.
- rwagner34Mar 26, 2021Copper Contributor
mtarler Is there a way for this to work if I am linking the changed cell to another worksheet? It does not seem to update the dashboard when the data changes in the cell that is pointing to another excel file.
In the cell that is changing:
='[rotation schedule.xlsx]Monday 1A'!$G$2
I have the code below on the worksheet, if I manually change the field it appears on the Dashboard, but it does not when I link it like above and the data changes. The field that is changing is in D2
Private Sub Worksheet_Change(ByVal Target As Range)
Dim dashUpdate As Range
Set dashUpdate = ThisWorkbook.Sheets("Dashboard").Range("$A$6")
If Intersect(Target, Range("$A$2:$D$47")) Is Nothing Then
Else
Target.EntireRow.Copy dashUpdate
End IfEnd Sub