jevi
Active Member
- Joined
- Apr 13, 2010
- Messages
- 339
- Office Version
- 2016
- Platform
- Windows
Hi All,
I am using this macro to update 4 graphs that I have created manually. The data that I have created the graphs is from B9:O54, the problem is that every 10 days I need to add other data so B55:O55 and I wanted the graphs to be updated automatically. This macro doesn't do it but it sounds only updates data if they are changed but always with the range B9:O54.
Is there a way to do it? My table of data is formatted as conditional formatting.
Thank you
I am using this macro to update 4 graphs that I have created manually. The data that I have created the graphs is from B9:O54, the problem is that every 10 days I need to add other data so B55:O55 and I wanted the graphs to be updated automatically. This macro doesn't do it but it sounds only updates data if they are changed but always with the range B9:O54.
Is there a way to do it? My table of data is formatted as conditional formatting.
Thank you
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim tbl As ListObject
Dim cht As ChartObject
' Definisci il nome della tabella
Set tbl = ThisWorkbook.Worksheets("NomeFoglio").ListObjects("NomeTabella") ' Modifica "NomeFoglio" con il nome del foglio e "NomeTabella" con il nome della tabella formattata
' Verifica se il cambiamento coinvolge la tabella
If Not Intersect(Target, tbl.DataBodyRange) Is Nothing Then
' Aggiorna tutti i grafici
For Each cht In ThisWorkbook.Worksheets("NomeFoglio").ChartObjects ' Modifica "NomeFoglio" con il nome del tuo foglio
cht.Chart.SetSourceData tbl.DataBodyRange
Next cht
End If
End Sub