Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 468
Default R/T error 1004 - But WHY?

ActiveCell.Formula = "=Counta(Selection.Offset(-1).end(xlUp) & "":"" &
Selection.Offset(-1))" 'Top to bottom
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 523
Default R/T error 1004 - But WHY?

Replace:

"=Counta(Selection.Offset(-1).end(xlUp) & "":"" & Selection.Offset(-1))"

with

"=Counta(" & Selection.Offset(-1).end(xlUp).address & ":" &
Selection.Offset(-1).address & ")"

Sam

"JMay" wrote:

ActiveCell.Formula = "=Counta(Selection.Offset(-1).end(xlUp) & "":"" &
Selection.Offset(-1))" 'Top to bottom

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default R/T error 1004 - But WHY?

That formula is not valid... Everything is inside the quotes so your formula
is exactly what is typed. Additionally the default return value of a range is
the value and not the address. You want something more like...

ActiveCell.Formula = "=Counta(" & Selection.Offset(-1).end(xlUp).address &
":" &
Selection.Offset(-1).address & ")" 'Top to bottom

--
HTH...

Jim Thomlinson


"JMay" wrote:

ActiveCell.Formula = "=Counta(Selection.Offset(-1).end(xlUp) & "":"" &
Selection.Offset(-1))" 'Top to bottom

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 468
Default R/T error 1004 - But WHY?

Jim,
Thank you so much - 1) for your fine/understandable explanation and 2)
the revised formula - WORKS GREAT!!
Jim

"Jim Thomlinson" wrote:

That formula is not valid... Everything is inside the quotes so your formula
is exactly what is typed. Additionally the default return value of a range is
the value and not the address. You want something more like...

ActiveCell.Formula = "=Counta(" & Selection.Offset(-1).end(xlUp).address &
":" &
Selection.Offset(-1).address & ")" 'Top to bottom

--
HTH...

Jim Thomlinson


"JMay" wrote:

ActiveCell.Formula = "=Counta(Selection.Offset(-1).end(xlUp) & "":"" &
Selection.Offset(-1))" 'Top to bottom

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default R/T error 1004 - But WHY?

This may not fit, but if you're trying to count the number of cells filled
between row 1 and the row above, you could use:

activecell.formular1c1 = "=counta(r1c:r[-1]c)")

r1c is row 1 of the same column
r[-1]c is the row above of the same column

If you had headers in rows 1:2 that you wanted to avoid:
activecell.formular1c1 = "=counta(r3c:r[-1]c)")



JMay wrote:

ActiveCell.Formula = "=Counta(Selection.Offset(-1).end(xlUp) & "":"" &
Selection.Offset(-1))" 'Top to bottom


--

Dave Peterson
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 general odbc error excel 2003 vba Mentos Excel Programming 5 January 24th 11 02:56 PM
runtime error '1004' application or object defined error Janis Excel Programming 4 November 18th 09 03:01 PM
Error when cell A1 is not active and xlInsideVertical border formatthrowing error 1004 [email protected] Excel Programming 7 August 7th 08 08:43 PM
Error handling error # 1004 Run-time error [email protected] Excel Programming 3 May 20th 08 02:23 PM
run-time error '1004': Application-defined or object-deifined error [email protected] Excel Programming 5 August 10th 05 09:39 PM


All times are GMT +1. The time now is 04:01 PM.

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"