ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Range within Formula (https://www.excelbanter.com/excel-programming/369587-range-within-formula.html)

Helmut

Range within Formula
 
Hi...I have....

Set rng = Range("G2:G" & lastrow)

want to use rng in formula:

ActiveCell.FormulaR1C1 = "=SUM(rng)"

How???

Don Guillett

Range within Formula
 
try just leaving the value

ActiveCell.value=SUM(rng)
--
Don Guillett
SalesAid Software

"Helmut" wrote in message
...
Hi...I have....

Set rng = Range("G2:G" & lastrow)

want to use rng in formula:

ActiveCell.FormulaR1C1 = "=SUM(rng)"

How???




Helmut

Range within Formula
 
Hi,
I get a 'compile error' on SUM
helmut

"Don Guillett" wrote:

try just leaving the value

ActiveCell.value=SUM(rng)
--
Don Guillett
SalesAid Software

"Helmut" wrote in message
...
Hi...I have....

Set rng = Range("G2:G" & lastrow)

want to use rng in formula:

ActiveCell.FormulaR1C1 = "=SUM(rng)"

How???





Don Guillett

Range within Formula
 
Sub dosum()
lastrow = cells(rows.count,"g").end(xlup).row
Set rng = Range("G2:G" & lastrow)
'ActiveCell.FormulaR1C1 = "=SUM(rng)"
ActiveCell = Application.Sum(rng)
End Sub



--
Don Guillett
SalesAid Software

"Helmut" wrote in message
...
Hi,
I get a 'compile error' on SUM
helmut

"Don Guillett" wrote:

try just leaving the value

ActiveCell.value=SUM(rng)
--
Don Guillett
SalesAid Software

"Helmut" wrote in message
...
Hi...I have....

Set rng = Range("G2:G" & lastrow)

want to use rng in formula:

ActiveCell.FormulaR1C1 = "=SUM(rng)"

How???







Helmut

Range within Formula
 
Don,
that worked, thanks. trying to apply it to COUNTIF as follows and it doesn't:

lastrow = Cells(Rows.Count, "g").End(xlUp).Row
Set rng = Range("G2:G" & lastrow)
ActiveCell = Application.COUNTIF(rng,""0"")"

HELP
Helmut
"Don Guillett" wrote:

Sub dosum()
lastrow = cells(rows.count,"g").end(xlup).row
Set rng = Range("G2:G" & lastrow)
'ActiveCell.FormulaR1C1 = "=SUM(rng)"
ActiveCell = Application.Sum(rng)
End Sub



--
Don Guillett
SalesAid Software

"Helmut" wrote in message
...
Hi,
I get a 'compile error' on SUM
helmut

"Don Guillett" wrote:

try just leaving the value

ActiveCell.value=SUM(rng)
--
Don Guillett
SalesAid Software

"Helmut" wrote in message
...
Hi...I have....

Set rng = Range("G2:G" & lastrow)

want to use rng in formula:

ActiveCell.FormulaR1C1 = "=SUM(rng)"

How???







Gary Keramidas

Range within Formula
 
you can try this

ActiveCell.Formula = "=SUM(" & rng.Address & ")"

--


Gary


"Helmut" wrote in message
...
Hi...I have....

Set rng = Range("G2:G" & lastrow)

want to use rng in formula:

ActiveCell.FormulaR1C1 = "=SUM(rng)"

How???




Don Guillett

Range within Formula
 
ctiveCell = Application.CountIf(rng, "0")


--
Don Guillett
SalesAid Software

"Helmut" wrote in message
...
Don,
that worked, thanks. trying to apply it to COUNTIF as follows and it
doesn't:

lastrow = Cells(Rows.Count, "g").End(xlUp).Row
Set rng = Range("G2:G" & lastrow)
ActiveCell = Application.COUNTIF(rng,""0"")"

HELP
Helmut
"Don Guillett" wrote:

Sub dosum()
lastrow = cells(rows.count,"g").end(xlup).row
Set rng = Range("G2:G" & lastrow)
'ActiveCell.FormulaR1C1 = "=SUM(rng)"
ActiveCell = Application.Sum(rng)
End Sub



--
Don Guillett
SalesAid Software

"Helmut" wrote in message
...
Hi,
I get a 'compile error' on SUM
helmut

"Don Guillett" wrote:

try just leaving the value

ActiveCell.value=SUM(rng)
--
Don Guillett
SalesAid Software

"Helmut" wrote in message
...
Hi...I have....

Set rng = Range("G2:G" & lastrow)

want to use rng in formula:

ActiveCell.FormulaR1C1 = "=SUM(rng)"

How???










All times are GMT +1. The time now is 08:02 AM.

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