LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default select next

from the immediate window as a demo

? activechart.HasAxis(xlValue, xlPrimary)
True
? activechart.HasAxis(xlValue,xlSecondary)
False


if activechart.hasAxis(xlValue, xlSecondary) then
' set attributes for this axis
--
Regards,
Tom Ogilvy


"BorisS" wrote:

maybe unrelated, but is there an equivalent of the "nothing" test for whether
or not there is a secondary axis? In other words, I have a combination of
graphs on some sheets, some with 2 and some 1 axis. I want to make sure all
axes are arial 10 bold, let's say. To do that, I would run what I had (minus
the number formatting). But I need, within the macro, to have the question
asked, "is there a second axis, and if so, then do XYZ". How would I get the
macro to ask that question, so I can then insert the secondary axis code
after that question. If there is no second axis, I would want it to go about
its business and skip the secondary axis code, so as to avoid a crash.
--
Boris


"Tom Ogilvy" wrote:

If you look at your code at the end, the selection is not a chartobject. I
gave you code to handle this in a previous thread.

here is a simpler version of that code:

Sub AA_SelectNext()
Dim obj As Object
If Not ActiveChart Is Nothing Then
Set obj = ActiveChart.Parent
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

Unfortunately, there is not one line of code that will do this that I am
aware of.
ActiveChart.Next does not work for what you want.

--
regards,
Tom Ogilvy


"BorisS" wrote:

so here is what I have (graphs), and it is not working:

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


again, however, my ideal scenario is not to have the macro go automatically
through each chart. Rather, I have some sheets where I need it just to go
through all, make changes I indicate, and then be done with the sheet.

but other sheets, I actually would prefer to go one by one, however not
having to hold the mouse and click on each successive graph. I want to
assign a shortcut key to run (I'll select the first graph), and end with a
line that basically does the same as simply clicking on the next graph (but
not running the macro over (which I understand for-each will force it to do).
Then once it's selected the next graph, I'll again hit the shortcut if I'm
sure I want to run it on that graph.

Thx for any further help.
--
Boris


"xlbo" wrote:

The exact syntax will depend on the objects you are trying to llop through
but essentially you need a For Each..Next loop through the object collection
so

For each objectVariable in SheetRef.objectCollection
Process objectVariable
Next

so to iterate through the textboxes on a sheet, you would reference the
SHAPES collection:

For Each shp In ActiveSheet.Shapes
MsgBox shp.Name
Next
--
Rgds, Geoff




"BorisS" wrote:

I need for a macro to run and then have the next object selected. What is
the one line that will get me that "select next object in the sheet" code? I
don't want it to go through all of them, just to do the equivalent of
clicking on the next graph I have in number order.

Thx.
--
Boris

 
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
VBA: Column Select then Data Select then return to cell A1 James C[_2_] Excel Discussion (Misc queries) 3 February 1st 10 11:35 AM
Using formulas to select cells (Ex: Select every nth cell in a col Lakeview Photographic Services Excel Discussion (Misc queries) 2 March 15th 07 02:17 PM
End Select without Select Case, Block If without End If errors Atreides Excel Programming 12 November 17th 06 05:10 PM
In Excel 2000, How do you select the whole of a worksheet (Select. Rascal Excel Discussion (Misc queries) 1 March 5th 05 12:03 AM
In Excel 2000, How do you select the whole of a worksheet (Select. Rascal Excel Discussion (Misc queries) 1 March 4th 05 11:59 PM


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