ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Can't activate chart (https://www.excelbanter.com/excel-programming/351045-cant-activate-chart.html)

Michael Smith

Can't activate chart
 
Hopefully someone knows this one quickly,..if so please help

This line fails when i run my macro, however when I step through line by
line, the macro works.

ActiveSheet.ChartObjects("Chart 1").Activate

Is there anyway to say..."active the chart that exists on this
worksheet"..is that the way to do it?

Thanks,
Mike


*** Sent via Developersdex http://www.developersdex.com ***

Dave Peterson

Can't activate chart
 
Option Explicit
Sub testme()

Dim wks As Worksheet
Set wks = ActiveSheet
With wks
If .ChartObjects.Count 0 Then
.ChartObjects(1).Activate
End If
End With
End Sub

maybe...

Michael Smith wrote:

Hopefully someone knows this one quickly,..if so please help

This line fails when i run my macro, however when I step through line by
line, the macro works.

ActiveSheet.ChartObjects("Chart 1").Activate

Is there anyway to say..."active the chart that exists on this
worksheet"..is that the way to do it?

Thanks,
Mike

*** Sent via Developersdex http://www.developersdex.com ***


--

Dave Peterson


All times are GMT +1. The time now is 05:23 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com