Hej!
Jag försöker få excel att samla data över vem som har gjort en given ändring och sedan föra in detta i ett diagram.
Jag får inte koden till att göra som jag vill. Koden är tänkt att fungera på hela arbetsboken, i ALLA celler.
Jag är lost...
Jag använder följande kod
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Dim r As Range
Set r = Target
If r.Cells.Count > 1 Then Set r = r.Cells(1)
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("Sheet2") ' Replace "Sheet2" with the name of the sheet that you want to use
ws.Cells(ws.Rows.Count, 1).End(xlUp).Offset(1, 0).Value = Sh.Name
ws.Cells(ws.Rows.Count, 1).End(xlUp).Offset(0, 1).Value = r.Address
ws.Cells(ws.Rows.Count, 1).End(xlUp).Offset(0, 2).Value = Now()
ws.Cells(ws.Rows.Count, 1).End(xlUp).Offset(0, 3).Value = Environ("USERNAME")
' Create chart
Dim cht As Chart
Set cht = ws.Shapes.AddChart.Chart
cht.SetSourceData Source:=ws.Range("A1:D" & ws.Rows.Count)
cht.ChartType = xlColumnClustered
End Sub
Vänligen,
Excelishard.