Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 577
Default code fails if graph is selected

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?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default code fails if graph is selected

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
--
HTH...

Jim Thomlinson


"Scott" wrote:

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?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 577
Default code fails if graph is selected

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

"Jim Thomlinson" wrote:

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
--
HTH...

Jim Thomlinson


"Scott" wrote:

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?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default code fails if graph is selected

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.
--
HTH...

Jim Thomlinson


"Scott" wrote:

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

"Jim Thomlinson" wrote:

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
--
HTH...

Jim Thomlinson


"Scott" wrote:

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?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default code fails if graph is selected

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


"Scott" wrote in message
...
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?





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,489
Default code fails if graph is selected

Hi,

Range("B1").EntireColumn.select

Cheers
Andy

Scott wrote:
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?


--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 577
Default code fails if graph is selected

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.

"Jim Thomlinson" wrote:

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.
--
HTH...

Jim Thomlinson


"Scott" wrote:

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

"Jim Thomlinson" wrote:

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
--
HTH...

Jim Thomlinson


"Scott" wrote:

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?

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
My code fails kirkm[_6_] Excel Programming 3 February 22nd 07 08:44 AM
Code fails if ran more than once Christy Excel Programming 11 August 31st 05 06:57 PM
ComboBox fails when last item selected first MBlake[_2_] Excel Programming 2 July 28th 05 07:51 PM
Filter Copy/Paste Fails - Two Ranges Selected? Craigm[_27_] Excel Programming 4 July 15th 05 04:16 PM
Excel Fails when add-in is selected Ron Excel Worksheet Functions 0 March 14th 05 12:18 AM


All times are GMT +1. The time now is 03:14 AM.

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"