ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Subscript out of range error message (https://www.excelbanter.com/excel-programming/427654-subscript-out-range-error-message.html)

Ayo

Subscript out of range error message
 
I am trying to run this code:

Private Sub Worksheet_Change(ByVal Target As Range)
Charts("Milestone Chart").Activate
With ActiveChart
.HasTitle = True
.ChartTitle.Text = Range("B3") & " " & Range("B4") & " - NLP2"
'"First Quarter Sales"
End With

Application.ScreenUpdating = False
If Target.Address() = "$B$3" Then
Call getMSaddress(Target)
ElseIf Target.Address() = "$B$4" Then
Call getMSaddress(Target)
End If
End Sub

but I am getting the error message on:
Charts("Milestone Chart").Activate

I don't know why this is since I named the chart "Milestone Chart". Any
ideas.
Thanks.


joel

Subscript out of range error message
 
Worksheet change can't active objects. try this

Private Sub Worksheet_Change(ByVal Target As Range)

With Charts("Milestone Chart")
.HasTitle = True
.ChartTitle.Text = Range("B3") & " " & Range("B4") & " - NLP2"
'"First Quarter Sales"
End With

Application.ScreenUpdating = False
If Target.Address() = "$B$3" Then
Call getMSaddress(Target)
ElseIf Target.Address() = "$B$4" Then
Call getMSaddress(Target)
End If
End Sub




"Ayo" wrote:

I am trying to run this code:

Private Sub Worksheet_Change(ByVal Target As Range)
Charts("Milestone Chart").Activate
With ActiveChart
.HasTitle = True
.ChartTitle.Text = Range("B3") & " " & Range("B4") & " - NLP2"
'"First Quarter Sales"
End With

Application.ScreenUpdating = False
If Target.Address() = "$B$3" Then
Call getMSaddress(Target)
ElseIf Target.Address() = "$B$4" Then
Call getMSaddress(Target)
End If
End Sub

but I am getting the error message on:
Charts("Milestone Chart").Activate

I don't know why this is since I named the chart "Milestone Chart". Any
ideas.
Thanks.


Ayo

Subscript out of range error message
 
This was what I had before. I changed it to:
Charts("Milestone Chart").Activate
With ActiveChart

when because I was getting the same error message.


"joel" wrote:

Worksheet change can't active objects. try this

Private Sub Worksheet_Change(ByVal Target As Range)

With Charts("Milestone Chart")
.HasTitle = True
.ChartTitle.Text = Range("B3") & " " & Range("B4") & " - NLP2"
'"First Quarter Sales"
End With

Application.ScreenUpdating = False
If Target.Address() = "$B$3" Then
Call getMSaddress(Target)
ElseIf Target.Address() = "$B$4" Then
Call getMSaddress(Target)
End If
End Sub




"Ayo" wrote:

I am trying to run this code:

Private Sub Worksheet_Change(ByVal Target As Range)
Charts("Milestone Chart").Activate
With ActiveChart
.HasTitle = True
.ChartTitle.Text = Range("B3") & " " & Range("B4") & " - NLP2"
'"First Quarter Sales"
End With

Application.ScreenUpdating = False
If Target.Address() = "$B$3" Then
Call getMSaddress(Target)
ElseIf Target.Address() = "$B$4" Then
Call getMSaddress(Target)
End If
End Sub

but I am getting the error message on:
Charts("Milestone Chart").Activate

I don't know why this is since I named the chart "Milestone Chart". Any
ideas.
Thanks.


joel

Subscript out of range error message
 
You are very limited on the type of operations you can perform with a
worksheet change macro. It is really only inteded to change the value of the
cell where the change was made. You can read data from any location but you
can only write data to the worksheet where the change was made. You also
can't active cells on other worksheets or charts.

"joel" wrote:

Worksheet change can't active objects. try this

Private Sub Worksheet_Change(ByVal Target As Range)

With Charts("Milestone Chart")
.HasTitle = True
.ChartTitle.Text = Range("B3") & " " & Range("B4") & " - NLP2"
'"First Quarter Sales"
End With

Application.ScreenUpdating = False
If Target.Address() = "$B$3" Then
Call getMSaddress(Target)
ElseIf Target.Address() = "$B$4" Then
Call getMSaddress(Target)
End If
End Sub




"Ayo" wrote:

I am trying to run this code:

Private Sub Worksheet_Change(ByVal Target As Range)
Charts("Milestone Chart").Activate
With ActiveChart
.HasTitle = True
.ChartTitle.Text = Range("B3") & " " & Range("B4") & " - NLP2"
'"First Quarter Sales"
End With

Application.ScreenUpdating = False
If Target.Address() = "$B$3" Then
Call getMSaddress(Target)
ElseIf Target.Address() = "$B$4" Then
Call getMSaddress(Target)
End If
End Sub

but I am getting the error message on:
Charts("Milestone Chart").Activate

I don't know why this is since I named the chart "Milestone Chart". Any
ideas.
Thanks.



All times are GMT +1. The time now is 01:52 PM.

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