ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Selecting a cell doesn't work????? (https://www.excelbanter.com/excel-programming/358157-selecting-cell-doesnt-work.html)

biosci[_3_]

Selecting a cell doesn't work?????
 

I have a change event procedure in Sheet1 that works very well with the
exception of probably the simplest component....selecting a cell. It
gives the following error message;

Runtime error '1004':

Select method of Range class failed

The line that it has the error on reads:

Range("BA1").select

I have writen page after page of macros and this usually works (as it
should). It should be quite a simple procedure. I have ensured that
the sheet is visible and unlocked etc, so that shouldn't be a problem.
The cell is on a different sheet to the sheet the procedure is iniated
from, but i wouldn't have thought that would cause an error. I am sure
the fault is simple, but can't for the life of me find the solution.

What am I doing worng and why won't this simplest of codes work for me?


--
biosci
------------------------------------------------------------------------
biosci's Profile: http://www.excelforum.com/member.php...o&userid=32827
View this thread: http://www.excelforum.com/showthread...hreadid=530296


JethroUK©

Selecting a cell doesn't work?????
 
try Range("BA1").activate


"biosci" wrote in
message ...

I have a change event procedure in Sheet1 that works very well with the
exception of probably the simplest component....selecting a cell. It
gives the following error message;

Runtime error '1004':

Select method of Range class failed

The line that it has the error on reads:

Range("BA1").select

I have writen page after page of macros and this usually works (as it
should). It should be quite a simple procedure. I have ensured that
the sheet is visible and unlocked etc, so that shouldn't be a problem.
The cell is on a different sheet to the sheet the procedure is iniated
from, but i wouldn't have thought that would cause an error. I am sure
the fault is simple, but can't for the life of me find the solution.

What am I doing worng and why won't this simplest of codes work for me?


--
biosci
------------------------------------------------------------------------
biosci's Profile:

http://www.excelforum.com/member.php...o&userid=32827
View this thread: http://www.excelforum.com/showthread...hreadid=530296




Dave Peterson

Selecting a cell doesn't work?????
 
Is your code behind a worksheet?

If yes, then the unqualified range will refer to the sheet holding the code.
And if that sheet isn't active, you can't select a range on that sheet.

worksheets("Sheet99").select
worksheets("sheet99").range("ba1").select

will work.

But you don't usually have to select a range to work with it.


biosci wrote:

I have a change event procedure in Sheet1 that works very well with the
exception of probably the simplest component....selecting a cell. It
gives the following error message;

Runtime error '1004':

Select method of Range class failed

The line that it has the error on reads:

Range("BA1").select

I have writen page after page of macros and this usually works (as it
should). It should be quite a simple procedure. I have ensured that
the sheet is visible and unlocked etc, so that shouldn't be a problem.
The cell is on a different sheet to the sheet the procedure is iniated
from, but i wouldn't have thought that would cause an error. I am sure
the fault is simple, but can't for the life of me find the solution.

What am I doing worng and why won't this simplest of codes work for me?

--
biosci
------------------------------------------------------------------------
biosci's Profile: http://www.excelforum.com/member.php...o&userid=32827
View this thread: http://www.excelforum.com/showthread...hreadid=530296


--

Dave Peterson

biosci[_4_]

Selecting a cell doesn't work?????
 

Thanks for the tip. I had tried that, but it didn't work.

I have managed to get around this problem by naming the cell which
allows me to enter values into it and use
range("whatever").offset("whatever").name = "myname" to change the
cell, which for most purposes works. Unfortunately I need to use the
line:

activecell.value=activecell.value

the reason I need to use this is that I am trying to plot a curve and
the cells that the X-axis values are taken from contain excel function
and for some reason the values are plottes in the order they are in (ie
1, 2, 3, 4, ) instead of the value in the cell. Apparently if I use

activecell.value=activecell.value

It will convert the cell from text to numbers.

I anyone can shed some more light on the situation with this added
info, it would be very handy.


--
biosci
------------------------------------------------------------------------
biosci's Profile: http://www.excelforum.com/member.php...o&userid=32827
View this thread: http://www.excelforum.com/showthread...hreadid=530296



All times are GMT +1. The time now is 06:05 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com