Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default VBA Can't select cell - what's up

Here's the code. It's within a subroutine which is called from serveral
other subroutines. I do a bit of EnableEvents and ScreenUpdating commands in
my code for various reasons. Most of the time this code works. But some
condition seems to exist that stops the 'range("D2").Select' from executing
properly. Haven't seen this before and I do have quite a lot of code in
Macros in many other Excel applictions.
=============================================
Excel.ActiveSheet.ChartObjects("Chart 52").Activate
Excel.ActiveSheet.ChartObjects("Chart 52").Select
Excel.Sheets("InterActive Chart").Range("D2").Value = "X3"
Excel.Sheets("InterActive Chart").Range("D2").Select
===============================================
The first 3 lines work properly, but I have no idea what Excel or VBA is
doing when I execute line 4. It does nothing, and I don't know where the
cursor is.
Any suggestions would be welcome.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default VBA Can't select cell - what's up

I'm not sure about charts but to select a range on a worksheet that
worksheet must be the selected worksheet. Assuming the same rule applies
for charts then "Chart 52" is selected when you are trying to select a range
on "InterActive Chart."

To avoid this problem change your code to read.

Excel.ActiveSheet.ChartObjects("Chart 52").Select
Excel.Sheets("InterActive Chart").Range("D2").Value = "X3"

Excel.Sheets("InterActive Chart").Select
Excel.Sheets("InterActive Chart").Range("D2").Select


Or, if possible"

With Excel.Sheets("InterActive Chart")
.Select
.Range("D2").Select
End With



--
My handle should tell you enough about me. I am not an MVP, expert, guru,
etc. but I do like to help.


"bill m" wrote in message
...
Here's the code. It's within a subroutine which is called from serveral
other subroutines. I do a bit of EnableEvents and ScreenUpdating commands

in
my code for various reasons. Most of the time this code works. But some
condition seems to exist that stops the 'range("D2").Select' from

executing
properly. Haven't seen this before and I do have quite a lot of code in
Macros in many other Excel applictions.
=============================================
Excel.ActiveSheet.ChartObjects("Chart 52").Activate
Excel.ActiveSheet.ChartObjects("Chart 52").Select
Excel.Sheets("InterActive Chart").Range("D2").Value = "X3"
Excel.Sheets("InterActive Chart").Range("D2").Select
===============================================
The first 3 lines work properly, but I have no idea what Excel or VBA is
doing when I execute line 4. It does nothing, and I don't know where the
cursor is.
Any suggestions would be welcome.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 301
Default VBA Can't select cell - what's up

Can't tell what the active sheet's name is, but if it isn't "Interactive
Chart", then you can't select cell D2 on it without it being activated
first. Try

Excel.Sheets("InterActive Chart").Activate
before the select statement.

"bill m" wrote in message
...
Here's the code. It's within a subroutine which is called from serveral
other subroutines. I do a bit of EnableEvents and ScreenUpdating commands

in
my code for various reasons. Most of the time this code works. But some
condition seems to exist that stops the 'range("D2").Select' from

executing
properly. Haven't seen this before and I do have quite a lot of code in
Macros in many other Excel applictions.
=============================================
Excel.ActiveSheet.ChartObjects("Chart 52").Activate
Excel.ActiveSheet.ChartObjects("Chart 52").Select
Excel.Sheets("InterActive Chart").Range("D2").Value = "X3"
Excel.Sheets("InterActive Chart").Range("D2").Select
===============================================
The first 3 lines work properly, but I have no idea what Excel or VBA is
doing when I execute line 4. It does nothing, and I don't know where the
cursor is.
Any suggestions would be welcome.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default VBA Can't select cell - what's up

You can only select a cell on the activesheet:

Add
Excel.Sheets("InterActive Chart").Select
before
Excel.Sheets("InterActive Chart").Range("D2").Select

(or just drop the .select/.activates completely and just work directly on the
ranges.)

bill m wrote:

Here's the code. It's within a subroutine which is called from serveral
other subroutines. I do a bit of EnableEvents and ScreenUpdating commands in
my code for various reasons. Most of the time this code works. But some
condition seems to exist that stops the 'range("D2").Select' from executing
properly. Haven't seen this before and I do have quite a lot of code in
Macros in many other Excel applictions.
=============================================
Excel.ActiveSheet.ChartObjects("Chart 52").Activate
Excel.ActiveSheet.ChartObjects("Chart 52").Select
Excel.Sheets("InterActive Chart").Range("D2").Value = "X3"
Excel.Sheets("InterActive Chart").Range("D2").Select
===============================================
The first 3 lines work properly, but I have no idea what Excel or VBA is
doing when I execute line 4. It does nothing, and I don't know where the
cursor is.
Any suggestions would be welcome.


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default nothing is working yet

Hope I didn't confuse anyone out there. The code below is a portion of code
I put in to test what was happening. The original code selected on a range
and copied the selection to another area. It isn't that the code does not
work it just doesn't work all the time. Most of the time it executes without
a problem. Just seems like it disassociates from Excel at least in the
select function. No matter how I write the code to select it just doesn't. I
have tried all the codes from the previous responsed before. Thought for
sure that reactivating the worksheet was the solution but that also has no
effect. Heres the code as it stands right now.
========================================
Private Sub Radio_Buttons()
Application.EnableEvents = False
Application.ScreenUpdating = False

Excel.Sheets("InterActive Chart").Activate
Worksheets("INTERACTIVE CHART").Select

Range("A295:BF295").Value = ""
Application.Goto Reference:="DateRange"
Selection.Copy
Range("A295").Select
Selection.PasteSpecial Paste:=xlValues
========================================
When it gets to 'Selection.Copy' I get 'Copy method of Range class failed'.
The subroutine executed as least 5 times and then got this error. For some
reason the program is just not in control of the Excel worksheet.

Thanks to everyone for the replies.



"bill m" wrote in message
...
Here's the code. It's within a subroutine which is called from serveral
other subroutines. I do a bit of EnableEvents and ScreenUpdating commands

in
my code for various reasons. Most of the time this code works. But some
condition seems to exist that stops the 'range("D2").Select' from

executing
properly. Haven't seen this before and I do have quite a lot of code in
Macros in many other Excel applictions.
=============================================
Excel.ActiveSheet.ChartObjects("Chart 52").Activate
Excel.ActiveSheet.ChartObjects("Chart 52").Select
Excel.Sheets("InterActive Chart").Range("D2").Value = "X3"
Excel.Sheets("InterActive Chart").Range("D2").Select
===============================================
The first 3 lines work properly, but I have no idea what Excel or VBA is
doing when I execute line 4. It does nothing, and I don't know where the
cursor is.
Any suggestions would be welcome.






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default VBA Can't select cell - what's up

Hope I didn't confuse anyone out there. The code below is a portion of code
I put in to test what was happening. The original code selected on a range
and copied the selection to another area. It isn't that the code does not
work it just doesn't work all the time. Most of the time it executes without
a problem. Just seems like it disassociates from Excel at least in the
select function. No matter how I write the code to select it just doesn't. I
have tried all the codes from the previous responsed before. Thought for
sure that reactivating the worksheet was the solution but that also has no
effect. Heres the code as it stands right now.
========================================
Private Sub Radio_Buttons()
Application.EnableEvents = False
Application.ScreenUpdating = False

Excel.Sheets("InterActive Chart").Activate
Worksheets("INTERACTIVE CHART").Select

Range("A295:BF295").Value = ""
Application.Goto Reference:="DateRange"
Selection.Copy
Range("A295").Select
Selection.PasteSpecial Paste:=xlValues
========================================
When it gets to 'Selection.Copy' I get 'Copy method of Range class failed'.
The subroutine executed as least 5 times and then got this error. For some
reason the program is just not in control of the Excel worksheet.

Thanks to everyone for the replies.


"bill m" wrote in message
...
Here's the code. It's within a subroutine which is called from serveral
other subroutines. I do a bit of EnableEvents and ScreenUpdating commands

in
my code for various reasons. Most of the time this code works. But some
condition seems to exist that stops the 'range("D2").Select' from

executing
properly. Haven't seen this before and I do have quite a lot of code in
Macros in many other Excel applictions.
=============================================
Excel.ActiveSheet.ChartObjects("Chart 52").Activate
Excel.ActiveSheet.ChartObjects("Chart 52").Select
Excel.Sheets("InterActive Chart").Range("D2").Value = "X3"
Excel.Sheets("InterActive Chart").Range("D2").Select
===============================================
The first 3 lines work properly, but I have no idea what Excel or VBA is
doing when I execute line 4. It does nothing, and I don't know where the
cursor is.
Any suggestions would be welcome.




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default VBA Can't select cell - what's up

I'd still drop the .select's:

Private Sub Radio_Buttons()
Application.EnableEvents = False
Application.ScreenUpdating = False

with Worksheets("INTERACTIVE CHART")
.Range("A295:BF295").Value = ""
.range("dateRange").copy
.range("a295").pastespecial paste:=xlvalues
end with

with application
.enableevents = true
.screenupdating = true
end with
end sub

This assumes that "dateRange" is on that "interactive chart" sheet.


It looks as though your original code is in a worksheet module. Unqualified
ranges refer to the sheet that owns the code--not the activesheet. So you'd
have to qualify each range object that refers to other sheets.




bill m wrote:

Hope I didn't confuse anyone out there. The code below is a portion of code
I put in to test what was happening. The original code selected on a range
and copied the selection to another area. It isn't that the code does not
work it just doesn't work all the time. Most of the time it executes without
a problem. Just seems like it disassociates from Excel at least in the
select function. No matter how I write the code to select it just doesn't. I
have tried all the codes from the previous responsed before. Thought for
sure that reactivating the worksheet was the solution but that also has no
effect. Heres the code as it stands right now.
========================================
Private Sub Radio_Buttons()
Application.EnableEvents = False
Application.ScreenUpdating = False

Excel.Sheets("InterActive Chart").Activate
Worksheets("INTERACTIVE CHART").Select

Range("A295:BF295").Value = ""
Application.Goto Reference:="DateRange"
Selection.Copy
Range("A295").Select
Selection.PasteSpecial Paste:=xlValues
========================================
When it gets to 'Selection.Copy' I get 'Copy method of Range class failed'.
The subroutine executed as least 5 times and then got this error. For some
reason the program is just not in control of the Excel worksheet.

Thanks to everyone for the replies.

"bill m" wrote in message
...
Here's the code. It's within a subroutine which is called from serveral
other subroutines. I do a bit of EnableEvents and ScreenUpdating commands

in
my code for various reasons. Most of the time this code works. But some
condition seems to exist that stops the 'range("D2").Select' from

executing
properly. Haven't seen this before and I do have quite a lot of code in
Macros in many other Excel applictions.
=============================================
Excel.ActiveSheet.ChartObjects("Chart 52").Activate
Excel.ActiveSheet.ChartObjects("Chart 52").Select
Excel.Sheets("InterActive Chart").Range("D2").Value = "X3"
Excel.Sheets("InterActive Chart").Range("D2").Select
===============================================
The first 3 lines work properly, but I have no idea what Excel or VBA is
doing when I execute line 4. It does nothing, and I don't know where the
cursor is.
Any suggestions would be welcome.



--

Dave Peterson
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
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
Select max value from 9 cells, copy cell col heading to other cell Struggling in Sheffield[_2_] New Users to Excel 6 March 11th 09 11:47 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
How to point to (select) a cell to the left from a cell where I enter the = equal sign? Dmitry Excel Discussion (Misc queries) 4 June 30th 06 06:49 AM
Select cell, Copy it, Paste it, Return to Previous cell spydor Excel Discussion (Misc queries) 1 December 30th 05 01:29 PM


All times are GMT +1. The time now is 12:26 AM.

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"