Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error Run-Time Error 1004 1

Status
Not open for further replies.

TaylorTot

Technical User
Dec 23, 2003
96
US
Hello,

I have the following problematic line of code:

AppXls.Selection.Formula = "=Sum(c2:" & Format(ActiveCell.Row - 1, "c#") & ")"

It is meant to sum the values in column c. . . but I am getting the following error:

Run-Time Error 1004 Application-defined or object-defined Error

Can anyone tell me what this error means and how to resolve it?
 

If you Google 'Error 1004' - the very first link will give you more info than you need.

Try it


Have fun.

---- Andy
 
AppXls.Selection.Formula = "=Sum(c2:" & Format([!]AppXls.[/!]ActiveCell.Row - 1, "c#") & ")"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi PH,

Thank you for your response. I am still getting the same error message?

 
What is the value of AppXls.ActiveCell.Row when the error raises ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Why not posting more code ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
This code works:

Dim LastRow As Long
LastRow = AppXls.Cells.Find(what:="*", After:=[A1], _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
AppXls.Rows(LastRow).Select
AppXls.ActiveCell.Offset(1, 0).Select
AppXls.ActiveCell.FormulaR1C1 = "Total:"
AppXls.ActiveCell.Offset(0, 1).Select
AppXls.Selection.Formula = "=Sum(b2:" & Format(ActiveCell.Row - 1, "b#") & ")"

But when I add this line:

AppXls.Selection.Formula = "=Sum(c2:" & Format(ActiveCell.Row - 1, "c#") & ")"

I get the error. I am able to sum one column, but when I try to sum 2 or more columns, I get the error.
 
Why using the format function (c as a special meaning for it !) ?
AppXls.Selection.Formula = "=Sum(c2:s" & (AppXls.ActiveCell.Row - 1) & ")"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
That is very close, except it does the following:

Sums everything for Column C: C2:E27
Sums Everything for Column D: D2:E27

The code I used was:

Dim LastRow As Long
LastRow = AppXls.Cells.Find(what:="*", After:=[A1], _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
AppXls.Rows(LastRow).Select
AppXls.ActiveCell.Offset(1, 0).Select
AppXls.ActiveCell.FormulaR1C1 = "Total:"
AppXls.ActiveCell.Offset(0, 1).Select
AppXls.Selection.Formula = "=Sum(b2:" & Format(ActiveCell.Row - 1, "b#") & ")"
AppXls.ActiveCell.Offset(0, 1).Select
AppXls.Selection.Formula = "=Sum(c2:s" & (AppXls.ActiveCell.Row - 1) & ")"
AppXls.ActiveCell.Offset(0, 1).Select
AppXls.Selection.Formula = "=Sum(d2:s" & (AppXls.ActiveCell.Row - 1) & ")"
AppXls.ActiveCell.Offset(0, 1).Select
AppXls.Selection.Formula = "=Sum(e2:s" & (AppXls.ActiveCell.Row - 1) & ")"

By the way thank you VERY much for working with me on this :)
 
Never mind I figured it out!! Thank you again for your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top