Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.charting
John
 
Posts: n/a
Default Select first chart in sheet

I would like to select the first chart in the sheet and set the min and max
values... the code says an object is not set... any help is appreciated!

Dim MinVal As Range
Dim MaxVal As Range
Dim ch As Chart
Set MinVal = ActiveSheet.Range("o17").Value
Set MaxVal = ActiveSheet.Range("o16").Value
ch = ActiveSheet.ChartObjects(1).Chart


For Each ch In ActiveSheet.ChartObjects
Select Case ch.ChartType
Case xlLineMarkers
With ch.Axes(xlCategory)
.MinimumScale = MinVal
.MaximumScale = MaxVal
End With
End Select
Next
End Sub
  #3   Report Post  
Posted to microsoft.public.excel.charting
JE McGimpsey
 
Posts: n/a
Default Select first chart in sheet

You seem to have your objects and variables confused.

"Set" is only used to assign objects to object or variant variables.
You're assigning cell values to MinVal and MaxVal, so they should not be
set to a range.

OTOH, you *are* attempting, for some reason, to assign a chart object
(but not a ChartObject) to the ChartObject variable ch. The error comes
from not using Set, but if you had, you'd get a type mismatch error.

But then you try to set ch to a ChartObject, not a Chart, so I suspect
you mean this instead:

Dim MinVal As Double
Dim MaxVal As Double
Dim ch As ChartObject
MinVal = ActiveSheet.Range("o17").Value
MaxVal = ActiveSheet.Range("o16").Value
For Each ch In ActiveSheet.ChartObjects
Select Case ch.Chart.ChartType
Case xlLineMarkers
With ch.Chart.Axes(xlCategory)
.MinimumScale = MinVal
.MaximumScale = MaxVal
End With
End Select
Next




In article ,
John wrote:

I would like to select the first chart in the sheet and set the min and max
values... the code says an object is not set... any help is appreciated!

Dim MinVal As Range
Dim MaxVal As Range
Dim ch As Chart
Set MinVal = ActiveSheet.Range("o17").Value
Set MaxVal = ActiveSheet.Range("o16").Value
ch = ActiveSheet.ChartObjects(1).Chart


For Each ch In ActiveSheet.ChartObjects
Select Case ch.ChartType
Case xlLineMarkers
With ch.Axes(xlCategory)
.MinimumScale = MinVal
.MaximumScale = MaxVal
End With
End Select
Next
End Sub

  #4   Report Post  
Posted to microsoft.public.excel.charting
John
 
Posts: n/a
Default Select first chart in sheet

JE I tried yours and it says unable to set the minimum scale for the axis...

Kelly I will take alook at that site!



"JE McGimpsey" wrote:

You seem to have your objects and variables confused.

"Set" is only used to assign objects to object or variant variables.
You're assigning cell values to MinVal and MaxVal, so they should not be
set to a range.

OTOH, you *are* attempting, for some reason, to assign a chart object
(but not a ChartObject) to the ChartObject variable ch. The error comes
from not using Set, but if you had, you'd get a type mismatch error.

But then you try to set ch to a ChartObject, not a Chart, so I suspect
you mean this instead:

Dim MinVal As Double
Dim MaxVal As Double
Dim ch As ChartObject
MinVal = ActiveSheet.Range("o17").Value
MaxVal = ActiveSheet.Range("o16").Value
For Each ch In ActiveSheet.ChartObjects
Select Case ch.Chart.ChartType
Case xlLineMarkers
With ch.Chart.Axes(xlCategory)
.MinimumScale = MinVal
.MaximumScale = MaxVal
End With
End Select
Next




In article ,
John wrote:

I would like to select the first chart in the sheet and set the min and max
values... the code says an object is not set... any help is appreciated!

Dim MinVal As Range
Dim MaxVal As Range
Dim ch As Chart
Set MinVal = ActiveSheet.Range("o17").Value
Set MaxVal = ActiveSheet.Range("o16").Value
ch = ActiveSheet.ChartObjects(1).Chart


For Each ch In ActiveSheet.ChartObjects
Select Case ch.ChartType
Case xlLineMarkers
With ch.Axes(xlCategory)
.MinimumScale = MinVal
.MaximumScale = MaxVal
End With
End Select
Next
End Sub


  #5   Report Post  
Posted to microsoft.public.excel.charting
John
 
Posts: n/a
Default Select first chart in sheet

changed one thing...
With ch.Chart.Axes(xlCategory) *** to xlValue
.MinimumScale = MinVal
.MaximumScale = MaxVal
End With

THANKS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! for the help!


"John" wrote:

JE I tried yours and it says unable to set the minimum scale for the axis...

Kelly I will take alook at that site!



"JE McGimpsey" wrote:

You seem to have your objects and variables confused.

"Set" is only used to assign objects to object or variant variables.
You're assigning cell values to MinVal and MaxVal, so they should not be
set to a range.

OTOH, you *are* attempting, for some reason, to assign a chart object
(but not a ChartObject) to the ChartObject variable ch. The error comes
from not using Set, but if you had, you'd get a type mismatch error.

But then you try to set ch to a ChartObject, not a Chart, so I suspect
you mean this instead:

Dim MinVal As Double
Dim MaxVal As Double
Dim ch As ChartObject
MinVal = ActiveSheet.Range("o17").Value
MaxVal = ActiveSheet.Range("o16").Value
For Each ch In ActiveSheet.ChartObjects
Select Case ch.Chart.ChartType
Case xlLineMarkers
With ch.Chart.Axes(xlCategory)
.MinimumScale = MinVal
.MaximumScale = MaxVal
End With
End Select
Next




In article ,
John wrote:

I would like to select the first chart in the sheet and set the min and max
values... the code says an object is not set... any help is appreciated!

Dim MinVal As Range
Dim MaxVal As Range
Dim ch As Chart
Set MinVal = ActiveSheet.Range("o17").Value
Set MaxVal = ActiveSheet.Range("o16").Value
ch = ActiveSheet.ChartObjects(1).Chart


For Each ch In ActiveSheet.ChartObjects
Select Case ch.ChartType
Case xlLineMarkers
With ch.Axes(xlCategory)
.MinimumScale = MinVal
.MaximumScale = MaxVal
End With
End Select
Next
End Sub


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Chart Property Confusion Arturo Charts and Charting in Excel 4 December 16th 05 05:13 AM
Still can select locked cells in protected sheet Andy New Users to Excel 11 October 29th 05 07:45 PM
Error 1004 using array in Sheet select. Trefor Excel Discussion (Misc queries) 4 September 7th 05 07:29 PM
Copying chart to another sheet Rebecca Excel Worksheet Functions 1 July 22nd 05 06:46 PM
HELP required: Insert -> Hyperlink -> ???(no CHART sheet name)!!! [email protected] Excel Worksheet Functions 1 April 27th 05 11:48 AM


All times are GMT +1. The time now is 10:41 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"