Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 111
Default Range within Formula

Hi...I have....

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

want to use rng in formula:

ActiveCell.FormulaR1C1 = "=SUM(rng)"

How???
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default 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???



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 111
Default 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???




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default 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???






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 111
Default 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???








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default 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???



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
How do I enter formula sum(range+range)*0.15 sumif(range=3) tkw Excel Discussion (Misc queries) 2 October 1st 09 09:17 PM
conditional formula: sum a range if text present in another range NeedAdvice777 Excel Discussion (Misc queries) 10 August 29th 06 04:51 PM
formula to sort a range so that it matches the exact rows of a column that is outside that range? steveo Excel Discussion (Misc queries) 1 June 18th 06 02:05 AM
Macro to input formula in range based on another range Peter Atherton Excel Programming 0 October 9th 03 12:47 AM
Range.Formula and Range question using Excel Automation [email protected] Excel Programming 0 September 19th 03 04:53 AM


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