VBA Excel
VBA Excel
Dim ws As Worksheet
Dim summarySheet As Worksheet
Set summarySheet = ThisWorkbook.Sheets("SUMMARY SHEET")
Dim rowCounter As Long
rowCounter = 2
' Check if there are any existing chart objects and delete them
If summarySheet.ChartObjects.Count > 0 Then
summarySheet.ChartObjects.Delete
End If
For i = 2 To lastRow
If directionName <> ws.Name Then
directionName = ws.Name
directionRow = rowCounter
directionChanged = True
End If
If directionChanged Then
summarySheet.Cells(directionRow, 1).Value = directionName
directionChanged = False ' Reset flag after setting
directionName
End If
Next i
End If
Next ws
End Sub