Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro to add count forumla with dynamic range


I am trying to use macro to add a COUNT() formula with a dynamic range.


A small example is

Code:
--------------------
Range("P7").Select
dynamicRow = 8 'may change dynamically
fixedStartRow = 5 - Row
ActiveCell.FormulaR1C1 = "=SUM("+fixedStartRow+":R[-1]C)"
--------------------


But the code above does not work!


Then I thought I can work ard iby making the ActiveCell dynamic.

Code:
--------------------
Range("P7").Select 'Selected cell may change dynamically
ActiveCell.FormulaR1C1 = "=SUM(P5:R[-1]C)"
--------------------


But this code produce the following in the cell box in excel sheet.
=SUM('P5':P6)


Why does it have 'P5' insteadd of just P5


Please advise! thanks!


--
falloutx
------------------------------------------------------------------------
falloutx's Profile: http://www.excelforum.com/member.php...o&userid=30560
View this thread: http://www.excelforum.com/showthread...hreadid=551270

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro to add count forumla with dynamic range


Hi

try

"=sum(r5c:r[-1]c)"

or

"=sum(r" & fixedStartRow & "c:r" & dynamicRow & "c)"

Note: Not sure if the line "fixedStartRow = 5 - Row" is working...
If Row is a variable, change it to other name due to the vba reserve
word

--
jindo
-----------------------------------------------------------------------
jindon's Profile: http://www.excelforum.com/member.php...fo&userid=1313
View this thread: http://www.excelforum.com/showthread.php?threadid=55127

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro to add count forumla with dynamic range


thanks!!!!


--
falloutx
------------------------------------------------------------------------
falloutx's Profile: http://www.excelforum.com/member.php...o&userid=30560
View this thread: http://www.excelforum.com/showthread...hreadid=551270

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
Formula to count every other column (dynamic range) Darlene New Users to Excel 7 November 18th 08 09:27 PM
forumla in dynamic ranges Dreamstar_1961 Excel Worksheet Functions 0 March 23rd 07 11:16 PM
Count dynamic range S Davis Excel Worksheet Functions 6 February 26th 07 07:51 PM
Dynamic Named Range count Matt Jensen Excel Programming 5 December 14th 04 01:04 PM
count and sum of dynamic range ???? wraithlead[_2_] Excel Programming 2 July 9th 04 09:48 PM


All times are GMT +1. The time now is 10:19 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"