Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Select charts by "Chart Names"

Hi,
Can some one help me to "Select charts by Names".
- I have multiple charts with different names in multiple work
sheets.
- These must be pasted to different slides in ppt.
- I planned to have worksheet names, chart names, slide nos. and chart
size in columns.
- So I want a syntax to select charts by names.

Thanks,
SAS.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 695
Default Select charts by "Chart Names"

if u no the names then try

ActiveSheet.ChartObjects("Shart 1").Activate

"sas" skrev:

Hi,
Can some one help me to "Select charts by Names".
- I have multiple charts with different names in multiple work
sheets.
- These must be pasted to different slides in ppt.
- I planned to have worksheet names, chart names, slide nos. and chart
size in columns.
- So I want a syntax to select charts by names.

Thanks,
SAS.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,489
Default Select charts by "Chart Names"

Hi,

Something like this.
The function returns a chart object, if found. It will search for chart
sheets is the chartname parameter is empty. Otherwise it will search for
a chart object on the named sheet.

'----------------
Sub X()

Dim strChartName As String
Dim strSheetName As String
Dim chtMyChart As Chart

strSheetName = "Sheet1"
strChartName = "Chart 1"

Set chtMyChart = ChartByName(strSheetName, strChartName)
If chtMyChart Is Nothing Then
MsgBox "Chart Not Found", vbExclamation
Else
MsgBox chtMyChart.Parent.Name
End If

strSheetName = "Chart1"
strChartName = ""

Set chtMyChart = ChartByName(strSheetName, strChartName)
If chtMyChart Is Nothing Then
MsgBox "Chart Not Found", vbExclamation
Else
MsgBox chtMyChart.Name
End If

End Sub

Function ChartByName(SheetName As String, ChartName As String) As Chart
'
' If ChartName is empty assum chart sheet rather than chart object
'
On Error GoTo ErrChartByName

If Len(ChartName) = 0 Then
' chart sheet
Set ChartByName = Charts(SheetName)
Else
Set ChartByName = _
Sheets(SheetName).ChartObjects(ChartName).Chart
End If
Exit Function

ErrChartByName:
Set ChartByName = Nothing
Exit Function

End Function
'-------------------------

Cheers
Andy

sas wrote:
Hi,
Can some one help me to "Select charts by Names".
- I have multiple charts with different names in multiple work
sheets.
- These must be pasted to different slides in ppt.
- I planned to have worksheet names, chart names, slide nos. and chart
size in columns.
- So I want a syntax to select charts by names.

Thanks,
SAS.


--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
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
Range("C100:D200").Select with variable names Fan924 Excel Programming 2 October 15th 07 03:54 PM
select fields names with "dot" guy Excel Programming 3 July 25th 07 01:50 PM
select & format "single" axis line in charts Guru Guy Charts and Charting in Excel 1 February 21st 06 03:36 AM
insert/names/apply - how to "select all" ? Wild Bill[_2_] Excel Programming 1 May 1st 05 10:45 AM
Using "Cells" to write "Range("A:A,H:H").Select" Trip Ives[_2_] Excel Programming 3 June 5th 04 03:13 PM


All times are GMT +1. The time now is 10:53 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"