Ho un grafico che modifica gli input dopo aver eseguito il mio codice.
Sub copy_values_for_chart()
With Worksheets("Working")
'clear chart consolidated data
LastRow = FindLastRow("Working")
.Range("Y4:AE" & LastRow).Clear
LastRow = FindLastRow("Working")
'copy Eolus T-1 data
.Range("Q4:W4").Copy
.Range("Y4").PasteSpecial Paste:=xlPasteValuesAndNumberFormats
'.Range("Q3").Value = "Date"
'calculate worst case P&L into col O
For Line = 4 To LastRow
If Range("O" & Line - 1).Value <> "" Then
Range("o" & Line).Value = Application.WorksheetFunction.Min(Range("J" & Line & ":" & "N" & Line))
End If
Next Line
'append rage data
.Range("I4:O" & LastRow).Copy
.Range("Y5").PasteSpecial Paste:=xlPasteValuesAndNumberFormats
'append copy of static data
.Range("A4 : G" & LastRow).Copy
LastRow = FindLastRow("Working")
.Range("Y" & LastRow + 1).PasteSpecial Paste:=xlPasteValuesAndNumberFormats
'sort consolidated data by date asc
LastRow = FindLastRow("Working")
.Range("Y3:AE" & LastRow).Sort key1:=Worksheets("Working").Range("Y3"), order1:=xlDescending, Header:=xlYes
'Application.CutCopyMode = False
End With
'update chart range data
Set DataRange = Worksheets("Working").Range("Y3 : AE" & LastRow) 'Change last row to number to include.
Worksheets("sheet1").ChartObjects("Chart 1").Chart.SetSourceData Source:=DataRange
End Sub
Prima di correre, ho 6 colonne sul lato sinistro e i dati sulla destra.
Dopo aver eseguito il mio codice ottengo 7 colonne sulla sinistra inclusa la data.
E dove la vecchia data era in un formato casuale sulla destra.
Qualcuno può aiutarmi a mantenere il modo in cui dovrebbe essere dopo l'esecuzione del mio codice?

