This code fails if a graph on the same sheet is selected (clicking inside the
graph)
Columns("B:B").Select
If I unselect the graph (clicking ouside the graph) then code runs fine.
What can I put in the code to make sure the graphs are not selected?
Jim Thomlinson - 27 Mar 2008 19:15 GMT
When the graph is selected there is no activesheet so
if activesheet is nothing then
msgbox "Sorry... Please de-select the graph before continuing..."
else
columns("B").Select

Signature
HTH...
Jim Thomlinson
> This code fails if a graph on the same sheet is selected (clicking inside the
> graph)
[quoted text clipped - 4 lines]
>
> What can I put in the code to make sure the graphs are not selected?
Scott - 27 Mar 2008 19:34 GMT
So I guess this line which is before doesnt mean anything when the chart is
selected
Sheets("XYZ").Select
BTW the error message is
Run-time error "1004"
Method 'Columns' of object '_Global' failed
> When the graph is selected there is no activesheet so
>
[quoted text clipped - 11 lines]
> >
> > What can I put in the code to make sure the graphs are not selected?
Jim Thomlinson - 27 Mar 2008 19:48 GMT
Sorry... Not ActiveSheet. Should be ActiveCell.
Try this perhaps (I dont't tend to select things in my macros as you really
don't need to so this is just a guess)
Activesheet.Columns("B").select
Otherwise if you want to post your code we could probalby get rid of the
selects and get around this whole mess.

Signature
HTH...
Jim Thomlinson
> So I guess this line which is before doesnt mean anything when the chart is
> selected
[quoted text clipped - 21 lines]
> > >
> > > What can I put in the code to make sure the graphs are not selected?
Scott - 31 Mar 2008 14:48 GMT
Being new to VBA programming I thought you had to select the sheet and select
the cells before performing any operation on them. Your suggestion
"Activesheet.Columns("B").select" worked. Thanks. Guess I still have a lot
to learn about VBA.
> Sorry... Not ActiveSheet. Should be ActiveCell.
>
[quoted text clipped - 31 lines]
> > > >
> > > > What can I put in the code to make sure the graphs are not selected?
Peter T - 27 Mar 2008 20:33 GMT
Try this -
If Not ActiveChart Is Nothing Then
If TypeName(ActiveChart.Parent) <> "ChartObject" Then
Windows(2).Activate
End If
End If
Columns("B:B").Select
Tut tut though, shouldn't be select'ing anyway <g>
Regards,
Peter T
> This code fails if a graph on the same sheet is selected (clicking inside the
> graph)
[quoted text clipped - 4 lines]
>
> What can I put in the code to make sure the graphs are not selected?
Andy Pope - 27 Mar 2008 21:17 GMT
Hi,
Range("B1").EntireColumn.select
Cheers
Andy
> This code fails if a graph on the same sheet is selected (clicking inside the
> graph)
[quoted text clipped - 4 lines]
>
> What can I put in the code to make sure the graphs are not selected?

Signature
Andy Pope, Microsoft MVP - Excel
http://www.andypope.info