Application Defined or object defined error

  • Thread starter Thread starter ExcelMonkey
  • Start date Start date
E

ExcelMonkey

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
 
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
 
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 *
 
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 said:
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 *
 
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 *
 
Back
Top