Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Run-time error '1004': Application defined or Object defined error

I am having difficulty with a run-time error '1004'.

Excel does not like it when I have substituted a variable
(linekount_I) for a relative cell address within a counta formula.

This generates the error:

ActiveCell.FormulaR1C1 = "=COUNTA(R[-linekount_I]C:R[-1]C) & ""
Invoice(s)"""

This works fine:

ActiveCell.FormulaR1C1 = "=COUNTA(R[-5]C:R[-1]C) & "" Invoice
(s)"""

I need to have the formula created with a varying number of rows. The
hard coded 5 will not suffice.

Any help would be appreciated
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Run-time error '1004': Application defined or Object defined error

The below code should work.

ActiveCell.FormulaR1C1 = "=COUNTA(R[-" & linekount_I & "]C:R[-1]C) & ""
Invoice(s)"""

If this post is helpful click Yes
---------------
Jacob Skaria
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Run-time error '1004': Application defined or Object defined error

from
ActiveCell.FormulaR1C1 = "=COUNTA(R[-linekount_I]C:R[-1]C) & ""

to
ActiveCell.FormulaR1C1 = "=COUNTA(R" & (-1 * linekount_I) & "C:R[-1]C)"


" wrote:

I am having difficulty with a run-time error '1004'.

Excel does not like it when I have substituted a variable
(linekount_I) for a relative cell address within a counta formula.

This generates the error:

ActiveCell.FormulaR1C1 = "=COUNTA(R[-linekount_I]C:R[-1]C) & ""
Invoice(s)"""

This works fine:

ActiveCell.FormulaR1C1 = "=COUNTA(R[-5]C:R[-1]C) & "" Invoice
(s)"""

I need to have the formula created with a varying number of rows. The
hard coded 5 will not suffice.

Any help would be appreciated

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 1004 Application defined or object defined error - WirelessPete Excel Programming 0 January 12th 09 11:00 PM
Run Time Error 1004: Application Defined or Object Defined Error BEEJAY Excel Programming 4 August 25th 08 01:52 PM
Export a chart in a GIF file. Run-time error '1004': Application-defined or object-defined error; [email protected] Excel Programming 4 September 16th 07 11:09 PM
Run-time error 1004. Application-defined or object-defined error Martin Brennan Excel Programming 2 June 7th 07 01:22 PM
Macro Run-time Error 1004 Application Defined or Object Defined Error Anddmx Excel Programming 6 June 9th 04 03:40 PM


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