G
Gerry
I've used a macro written by Tushar Mehta to delink charts in my
worksheet.
I need to delink all worksheets and have tried adding some code to
activate the charts one at a time. It seemed to work fine one time,
but it's now giving me problems. Here is the code. Help me out if
you can.
TIA
Gerry
Sub DeLinkCharts()
''' Thanks to Tushar Mehta
Dim ChartNm As String
Dim ChtObj As ChartObject
Dim mySeries As Series
Dim sChtName As String
''' Make sure a chart is selected
For Each ChtObj In ActiveSheet.ChartObjects
ChartNm = ChtObj.Name
ActiveSheet.ChartObjects(ChartNm).Activate
ActiveChart.ChartArea.Select
On Error Resume Next
sChtName = ActiveChart.Name
If Err.Number <> 0 Then
MsgBox "This functionality is available only for charts " _
& "or chart objects"
Exit Sub
End If
If TypeName(Selection) = "ChartObject" Then
ActiveSheet.ChartObjects(ChartNm).Activate
End If
On Error GoTo 0
''' Loop through all series in active chart
For Each mySeries In ActiveChart.SeriesCollection
'''' Convert X and Y Values to arrays of values
mySeries.XValues = mySeries.XValues
mySeries.Values = mySeries.Values
mySeries.Name = mySeries.Name
Next mySeries
Next
Range("A1").Select
End Sub
worksheet.
I need to delink all worksheets and have tried adding some code to
activate the charts one at a time. It seemed to work fine one time,
but it's now giving me problems. Here is the code. Help me out if
you can.
TIA
Gerry
Sub DeLinkCharts()
''' Thanks to Tushar Mehta
Dim ChartNm As String
Dim ChtObj As ChartObject
Dim mySeries As Series
Dim sChtName As String
''' Make sure a chart is selected
For Each ChtObj In ActiveSheet.ChartObjects
ChartNm = ChtObj.Name
ActiveSheet.ChartObjects(ChartNm).Activate
ActiveChart.ChartArea.Select
On Error Resume Next
sChtName = ActiveChart.Name
If Err.Number <> 0 Then
MsgBox "This functionality is available only for charts " _
& "or chart objects"
Exit Sub
End If
If TypeName(Selection) = "ChartObject" Then
ActiveSheet.ChartObjects(ChartNm).Activate
End If
On Error GoTo 0
''' Loop through all series in active chart
For Each mySeries In ActiveChart.SeriesCollection
'''' Convert X and Y Values to arrays of values
mySeries.XValues = mySeries.XValues
mySeries.Values = mySeries.Values
mySeries.Name = mySeries.Name
Next mySeries
Next
Range("A1").Select
End Sub