Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Dynamic range w/in formula in macro


Hello,

I have been trying to figure out if there is a way to allow a dynamic
range within a formula in VBA.

I have this static range, but the end row could change as data is
added/deleted:

Range("K11").Select
ActiveCell.FormulaR1C1 = "=COUNTIF(R[-9]C[-6]:R[18]C[-6],"""")"

I'd like to be able to change the R[18] to whichever row the user would
put into an input box at the beginning of the macro.

Thanks!


--
Trixie

~TRIXIE
------------------------------------------------------------------------
Trixie's Profile: 438
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=175466

Microsoft Office Help

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Dynamic range w/in formula in macro


Hi, I'm no VBA buff, but since the formula is essentially a text string,
you can just concatenate it with any other value, like


Code:
--------------------

stRow = InputBox("Which row are we interested in?")
Range("K11").Select
ActiveCell.FormulaR1C1 = "=COUNTIF(R[-9]C[-6]:R[" & stRow & "]C[-6],"""")"


--------------------


I may be completely off, but I'm sure I'll get corrected :)


--
teylyn

Teylyn -- 'teylyn.posterous.com' (http://teylyn.posterous.com)
------------------------------------------------------------------------
teylyn's Profile: 983
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=175466

Microsoft Office Help

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 834
Default Dynamic range w/in formula in macro

No need for the select

stRow = InputBox("Which row are we interested in?")
Range("K11").FormulaR1C1 = "=COUNTIF(R[-9]C[-6]:R[" & stRow &
"]C[-6],"""")"

HTH

Bob

"teylyn" wrote in message
...

Hi, I'm no VBA buff, but since the formula is essentially a text string,
you can just concatenate it with any other value, like


Code:
--------------------

stRow = InputBox("Which row are we interested in?")
Range("K11").Select
ActiveCell.FormulaR1C1 = "=COUNTIF(R[-9]C[-6]:R[" & stRow &
"]C[-6],"""")"


--------------------


I may be completely off, but I'm sure I'll get corrected :)


--
teylyn

Teylyn -- 'teylyn.posterous.com' (http://teylyn.posterous.com)
------------------------------------------------------------------------
teylyn's Profile: 983
View this thread:
http://www.thecodecage.com/forumz/sh...d.php?t=175466

Microsoft Office Help



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
Dynamic Range Name Macro Jonathan Cooper Excel Discussion (Misc queries) 3 March 24th 08 09:04 PM
dynamic range in a macro MJKelly Excel Programming 2 November 19th 07 11:48 PM
dynamic range based on criteria, within a dynamic range, passed to a function [email protected] Excel Programming 5 October 9th 07 10:13 PM
creating a dynamic range based on criteria, within a dynamic range, and passing it to a function [email protected] Excel Programming 0 October 9th 07 05:22 PM
Dynamic Range with unused formula messing up x axis on dynamic graph [email protected] Charts and Charting in Excel 2 February 2nd 06 08:02 PM


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