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 |
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/ |
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/ |
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/ |
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 |
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/ |
All times are GMT +1. The time now is 01:28 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com