Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default next object selection

Dim cobj As ChartObject

For Each cobj In ActiveSheet.ChartObjects
cobj.select '<== added line
ActiveChart.Axes(xlValue, xlPrimary).Select
Selection.TickLabels.NumberFormat = "#,##0.0_);[Red](#,##0.0)"
Selection.TickLabels.AutoScaleFont = True
With Selection.TickLabels.Font
..Name = "Arial"
..FontStyle = "Regular"
..Size = 10
..Strikethrough = False
..Superscript = False
..Subscript = False
..OutlineFont = False
..Shadow = False
..Underline = xlUnderlineStyleNone
..ColorIndex = xlAutomatic
..Background = xlAutomatic
End With
ActiveChart.Axes(xlValue, xlSecondary).Select
Selection.TickLabels.NumberFormat = "#,##0_);[Red](#,##0)"
Selection.TickLabels.AutoScaleFont = True
With Selection.TickLabels.Font
..Name = "Arial"
..FontStyle = "Regular"
..Size = 10
..Strikethrough = False
..Superscript = False
..Subscript = False
..OutlineFont = False
..Shadow = False
..Underline = xlUnderlineStyleNone
..ColorIndex = xlAutomatic
..Background = xlAutomatic
End With

Next cobj

End Sub


for your previous question about selecting the next chartobject.
This code selects the next chartobject:

Sub AA_SelectNext()
Dim obj As Object
s = TypeName(Selection)
Set obj = Selection
Do Until LCase(s) = "chartobject"
Set obj = obj.Parent
s = TypeName(obj)
Debug.Print s
If LCase(s) = "worksheet" Then
MsgBox "Chart Object not selected"
Exit Sub
End If
Loop
If LCase(TypeName(obj)) = "chartobject" Then
i = obj.Index
obj.TopLeftCell.Select
If i < ActiveSheet.ChartObjects.Count Then
ActiveSheet.ChartObjects(i + 1).Select
Else
ActiveSheet.ChartObjects(1).Select
End If
Else
MsgBox "chartObject is not selected"
End If

End Sub

--
Regards,
Tom Ogilvy




"BorisS" wrote:

Tom, tried the code I had (combination of your two pieces) and am not seeing
the macro move through the objects. I am stepping through, and upon
finishing the code, it does not go through to the next object. Just sits
where it is, with the first graph selected. Here is what I have as code:

Dim cobj As ChartObject

For Each cobj In ActiveSheet.ChartObjects

ActiveChart.Axes(xlValue, xlPrimary).Select
Selection.TickLabels.NumberFormat = "#,##0.0_);[Red](#,##0.0)"
Selection.TickLabels.AutoScaleFont = True
With Selection.TickLabels.Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.Background = xlAutomatic
End With
ActiveChart.Axes(xlValue, xlSecondary).Select
Selection.TickLabels.NumberFormat = "#,##0_);[Red](#,##0)"
Selection.TickLabels.AutoScaleFont = True
With Selection.TickLabels.Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.Background = xlAutomatic
End With

Next cobj

End Sub


It works on just one fine. But it doesn't step through. Can you decipher
where I am screwing up?
--
Boris


"Tom Ogilvy" wrote:

Dim cobj as ChartObject
for each cobj in Activesheet.ChartObjects


Next cobj

Keep track of the index number of where you are


just to illustrate from the immediate window:

? activesheet.chartobjects.count
4
? activesheet.chartobjects(1).name
Chart 1
? activesheet.chartobjects(3).name
Chart 3
activesheet.chartobjects(2).Select
? selection.name
Chart 2

--
Regards,
Tom Ogilvy



"BorisS" wrote:

had Tom help me previously with following command as part of larger code

activesheet.ChartObjects(1).Chart.Axes(xlValue,xlS econdary).TickLabels.Font.Name
Book Antiqua

This, as I understand it, depends on knowing which object you want to
select. But if I am using '07 (in case it matters) and want the macro to 1)
determine how many objects are on the page and the 2) go through each object
one by one, and complete a set of steps, how would I do that?

Additionally, if I were to want to not have it go through automatically and
do each, what is the final command I can put on my code to say, effectively,
"pick the next object on the sheet."

Thx in advance.


--
Boris

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
Object Selection W2 Excel Discussion (Misc queries) 2 August 26th 08 06:07 PM
Selection with one object Arne Hegefors Excel Programming 3 August 30th 06 04:44 PM
Object Variable Not Set Error on Selection object Jean Excel Worksheet Functions 3 July 24th 06 06:45 PM
Object Type of a selection... counting rows in a selection Acid-Sky[_2_] Excel Programming 3 August 23rd 05 09:53 AM
Selection object in Excel 2002 Franco22 Excel Programming 2 April 29th 04 09:36 PM


All times are GMT +1. The time now is 12:54 PM.

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

About Us

"It's about Microsoft Excel"