Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Application Defined or object defined error

I have a macro which is failing on line three of this code:

Sheets("Sheet1").Select
Range("C2").Select
ActiveCell.Offset(BlockRow - 3, Seed - 1) = BlockSize

It Selects the Sheet and the cell but cannot execute the last line.
Blocksize is a variable which is defined as:

?Blocksize
0


The error message is:
Run time Error 1004
Application Defined or object defined error.

What am I doing wrong?

Thank

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Application Defined or object defined error

Can't tell from your macro, but if BlockRow is less than 2 then the your
Offset is trying to reference a cell off the top of the worksheet.

Note that you don't need to select anything:

Sheets("Sheet1").Range("C2").Offset(BlockRow - 3, Seed - 1) = BlockSize


In article ,
ExcelMonkey wrote:

I have a macro which is failing on line three of this code:

Sheets("Sheet1").Select
Range("C2").Select
ActiveCell.Offset(BlockRow - 3, Seed - 1) = BlockSize

It Selects the Sheet and the cell but cannot execute the last line.
Blocksize is a variable which is defined as:

?Blocksize
0


The error message is:
Run time Error 1004
Application Defined or object defined error.

What am I doing wrong?

Thanks


---
Message posted from http://www.ExcelForum.com/

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Application Defined or object defined error

That's not strange ExcelMonkey ( You named yourself :) ) .
You select cel C2 as the active cell with Range("C2").Select.

In the last statement you then tell Excel to select a cell three (
blockrow - 3 = 0 - 3 = -3) to the left of cell C2.
The maximum Excel can go to the left is however 2 ( -2) and thereby in
column A.

--
Regards,
Auk Ales

* Please reply to this newsgroup only *
* I will not react on unsolicited e-mails *

"ExcelMonkey " wrote in message
...
I have a macro which is failing on line three of this code:

Sheets("Sheet1").Select
Range("C2").Select
ActiveCell.Offset(BlockRow - 3, Seed - 1) = BlockSize

It Selects the Sheet and the cell but cannot execute the last line.
Blocksize is a variable which is defined as:

?Blocksize
0


The error message is:
Run time Error 1004
Application Defined or object defined error.

What am I doing wrong?

Thanks


---
Message posted from http://www.ExcelForum.com/



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Application Defined or object defined error

Sorry, made an error. Mixed some things (rows and columns ; BockRow and
BlockSize) up.
Anyhow : Is it sure that BlockRow - 3 = -1 Excel can't go (from C2)
more than 1 row up
and : Is it sure that Seed - 1 = -2 Excel can't go (from C2)
more than 2 columns to the left.

--
Regards,
Auk Ales

* Please reply to this newsgroup only *
* I will not react on unsolicited e-mails *

"A.W.J. Ales" wrote in message
...
That's not strange ExcelMonkey ( You named yourself :) ) .
You select cel C2 as the active cell with Range("C2").Select.

In the last statement you then tell Excel to select a cell three (
blockrow - 3 = 0 - 3 = -3) to the left of cell C2.
The maximum Excel can go to the left is however 2 ( -2) and thereby in
column A.

--
Regards,
Auk Ales

* Please reply to this newsgroup only *
* I will not react on unsolicited e-mails *

"ExcelMonkey " wrote in

message
...
I have a macro which is failing on line three of this code:

Sheets("Sheet1").Select
Range("C2").Select
ActiveCell.Offset(BlockRow - 3, Seed - 1) = BlockSize

It Selects the Sheet and the cell but cannot execute the last line.
Blocksize is a variable which is defined as:

?Blocksize
0


The error message is:
Run time Error 1004
Application Defined or object defined error.

What am I doing wrong?

Thanks


---
Message posted from http://www.ExcelForum.com/





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Application Defined or object defined error

Sorry, BlockRow was less than 2 which crashed the code. My fault..

--
Message posted from http://www.ExcelForum.com



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Application Defined or object defined error

Oke and thanks for the feedback. It's always nice to hear that things have
been solved.

--
Regards,
Auk Ales

* Please reply to this newsgroup only *
* I will not react on unsolicited e-mails *

"ExcelMonkey " wrote in message
...
Sorry, BlockRow was less than 2 which crashed the code. My fault...


---
Message posted from http://www.ExcelForum.com/



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
Run-time error '50290': Application-defined or object-defined erro Macro button Excel Discussion (Misc queries) 1 March 12th 09 10:59 AM
Application-defined or object-defined error Please Help [email protected] Excel Discussion (Misc queries) 1 April 3rd 06 01:00 PM
Runtime Error 1004 -- Application Defined or Object Defined Error John[_51_] Excel Programming 3 September 4th 03 04:28 PM
VBA - Application-defined or object-defined error tina salgia Excel Programming 0 August 24th 03 10:35 PM
VBA - Application-defined or object-defined error Chip Pearson Excel Programming 0 August 24th 03 08:43 PM


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