ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   formula error (https://www.excelbanter.com/excel-programming/411092-formula-error.html)

Raul Sousa

formula error
 
I am having some problems with this code. This is part of a macro.

This part is working fine
ActiveCell.FormulaR1C1 = "=SUM(RC[" & -Sheets.Count & "]:RC[-2])"
But I want to include this part
-(Cells(11, Sheets.Count + 1))
Thus having
ActiveCell.FormulaR1C1 = "=SUM(RC[" & -Sheets.Count & "]:RC[-2])-" &
(Cells(11, Sheets.Count + 1))
This way it does not work. It gives me an error, and I can understand why.

Another problem is that the result of the following code is:
ActiveCell.FormulaR1C1 = "=SUM(" & Sheets(1).Name & ":" &
Sheets(Sheets.Count).Name & "!e11)"
=SUM(tps1:tps26!e11)
The expression e11 appears between €˜. I need to remove this €˜, but dont
know who.

Any help is most welcome.


Bob Phillips

formula error
 
The first one works fine for me as long as that cell contains a number.

Second

ActiveCell.Formula = "=SUM(" & Sheets(1).Name & ":" &
Sheets(Sheets.Count).Name & "!E11)"


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Raul Sousa" wrote in message
...
I am having some problems with this code. This is part of a macro.

This part is working fine
ActiveCell.FormulaR1C1 = "=SUM(RC[" & -Sheets.Count & "]:RC[-2])"
But I want to include this part
-(Cells(11, Sheets.Count + 1))
Thus having
ActiveCell.FormulaR1C1 = "=SUM(RC[" & -Sheets.Count & "]:RC[-2])-" &
(Cells(11, Sheets.Count + 1))
This way it does not work. It gives me an error, and I can understand why.

Another problem is that the result of the following code is:
ActiveCell.FormulaR1C1 = "=SUM(" & Sheets(1).Name & ":" &
Sheets(Sheets.Count).Name & "!e11)"
=SUM(tps1:tps26!'e11')
The expression e11 appears between ''. I need to remove this '', but don't
know who.

Any help is most welcome.





All times are GMT +1. The time now is 07:04 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com