Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default I need to give index number to charts

i have 5 charts in a sheet . i want to access this charts using index
number . need vba code to give desire index numbers to charts i.e i
want to programmitically give index number to all charts . i want to
assign the mentioned index numbers to those charts

charts name index number

charts 1 1

charts 2 2

charts 3 3

i have code which renames the charts present in the worksheet but the
index number remains 1 for all charts . say if have 3 charts in a
sheet i have to execute this below program thrice inorder to have
index number 1 , 2 and 3 for the charts . Before running this program
all the 3 charts had same index number and same chart name



Sub Renamecharts()

Dim chtobj As ChartObject
Dim Msg As String
Dim n As Integer

n = ActiveSheet.ChartObjects.Count
Msg = "Chart List for Sheet " & vbTab & ActiveSheet.Name & vbTab & "No
charts = " & n & vbCrLf & vbCrLf
Msg = Msg & "Name " & vbTab & vbTab & "Index" & vbCrLf
i = 0
For Each chtobj In ActiveSheet.ChartObjects
i = i + 1
chtobj.Activate
chtobj.Name = "Charts" & i
'chtobj.Index= i ' '''''''''' i want to do something like this
'''''''''''''''''''''''
Debug.Print chtobj.Name
Msg = Msg & chtobj.Name & vbTab & vbTab & chtobj.Index & vbCrLf
Next chtobj
out = MsgBox(Msg, , "Chart List")

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default I need to give index number to charts

I'm pretty sure you won't be able to do this. Index is a read only
property set by Excel - presumably based on the order in which the
charts are created.

Why do want to change the index? Given the chartobject name you
should be able to access the chart anyway. If you could explain why
you want to change the index we might be able to come up with an
alternative solution.

Cheers,
Andrew


On 23 June, 13:36, vicky wrote:
i have 5 charts in a sheet . i want to access *this charts using index
number . need vba code to give desire index numbers to *charts i.e i
want to programmitically give index number to all charts . i want to
assign the mentioned index numbers to those charts

charts name * *index number

charts 1 * * * * * *1

charts 2 * * * * * *2

charts 3 * * * * * *3

i have code which renames the charts present in the worksheet but the
index number remains 1 for all charts . say if have 3 charts in a
sheet i have to execute this below program thrice inorder to have
index number 1 , 2 and 3 for the charts . Before running this program
all the 3 charts had same index number and same chart name

Sub Renamecharts()

Dim chtobj As ChartObject
Dim Msg As String
Dim n As Integer

n = ActiveSheet.ChartObjects.Count
Msg = "Chart List for Sheet " & vbTab & ActiveSheet.Name & vbTab & "No
charts = " & n & vbCrLf & vbCrLf
Msg = Msg & "Name " & vbTab & vbTab & "Index" & vbCrLf
i = 0
For Each chtobj In ActiveSheet.ChartObjects
* * i = i + 1
* * chtobj.Activate
* * chtobj.Name = "Charts" & i
* * 'chtobj.Index= i * ' * '''''''''' i want to do something like this
'''''''''''''''''''''''
Debug.Print chtobj.Name
* * Msg = Msg & chtobj.Name & vbTab & vbTab & chtobj.Index & vbCrLf
Next chtobj
out = MsgBox(Msg, , "Chart List")

End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default I need to give index number to charts

wel i have graphs wit same index numbers. i can rename the charts
only when i have unique index numbers . if i have 3 charts and then i
have to execute my code RenameCharts() thrice inorder to have unique
index number to the charts .
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default I need to give index number to charts

on 6/23/2010, vicky supposed :
i have 5 charts in a sheet . i want to access this charts using index
number . need vba code to give desire index numbers to charts i.e i
want to programmitically give index number to all charts . i want to
assign the mentioned index numbers to those charts

charts name index number

charts 1 1

charts 2 2

charts 3 3

i have code which renames the charts present in the worksheet but the
index number remains 1 for all charts . say if have 3 charts in a
sheet i have to execute this below program thrice inorder to have
index number 1 , 2 and 3 for the charts . Before running this program
all the 3 charts had same index number and same chart name



Sub Renamecharts()

Dim chtobj As ChartObject
Dim Msg As String
Dim n As Integer

n = ActiveSheet.ChartObjects.Count
Msg = "Chart List for Sheet " & vbTab & ActiveSheet.Name & vbTab & "No
charts = " & n & vbCrLf & vbCrLf
Msg = Msg & "Name " & vbTab & vbTab & "Index" & vbCrLf
i = 0
For Each chtobj In ActiveSheet.ChartObjects
i = i + 1
chtobj.Activate
chtobj.Name = "Charts" & i
'chtobj.Index= i ' '''''''''' i want to do something like this
'''''''''''''''''''''''
Debug.Print chtobj.Name
Msg = Msg & chtobj.Name & vbTab & vbTab & chtobj.Index & vbCrLf
Next chtobj
out = MsgBox(Msg, , "Chart List")

End Sub


In support of Andrew's reply, could you not create your own charts
collection and assign the index there? Alternatively, if the number of
charts is known ahead of runtime, you could use an enum to identify
charts in code.

HTH

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


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
How do i give unique number in set of duplicate number? Vilish Excel Discussion (Misc queries) 2 May 12th 09 03:33 PM
how to give an automatic number Tia[_3_] Excel Worksheet Functions 1 August 14th 08 03:43 PM
Give multiple charts on a worksheet/workbook same header or footer Ches Excel Discussion (Misc queries) 8 July 4th 05 09:29 PM
Give multiple charts on a worksheet/workbook same header or footer Ches Charts and Charting in Excel 2 July 4th 05 04:58 PM
Minutes multiplied by a number to give a number Mally Excel Discussion (Misc queries) 4 January 19th 05 05:21 PM


All times are GMT +1. The time now is 04:43 PM.

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"