+ Reply to Thread
Results 1 to 7 of 7

Change Static Range of Formula to Dynamic Range

  1. #1
    Valued Forum Contributor
    Join Date
    04-11-2006
    MS-Off Ver
    2007
    Posts
    438

    Question Change Static Range of Formula to Dynamic Range

    Hello all,

    I have this code below that was created by the macro recorder. The only problem I'm having is that I need to run this code again and again and the number of rows will always be different.

    How can I change the recorded code below to select the current region of each relevant area and be dynamic instead of static?


    ActiveCell.FormulaR1C1 = "=COUNTIFS(R2C18:R50C18,RC[3],R2C14:R50C14,""<>"" &"""")/SUMIF(R2C18:R50C18,RC[3],R2C7:R50C7)"
    Thanks much!
    Last edited by duugg; 01-21-2014 at 05:14 PM.

  2. #2
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Change Static Range of Formula to Dynamic Range

    You may try:
    Please Login or Register  to view this content.
    • Please remember to mark threads Solved with Thread Tools link at top of page.
    • Please use code tags when posting code: [code]Place your code here[/code]
    • Please read Forum Rules

  3. #3
    Valued Forum Contributor
    Join Date
    04-11-2006
    MS-Off Ver
    2007
    Posts
    438

    Re: Change Static Range of Formula to Dynamic Range

    Izandol,

    Yes, that worked. Thank you for that!

    Is there some "rule-of-thumb" that I can follow to apply that code to similar sections?

    Thanks again

  4. #4
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Change Static Range of Formula to Dynamic Range

    Simply replace the last row number in the formula string with some text that will not appear elsewhere - in the example, I used 'lastrow'. You may then use Replace to replace this text with the actual last row number you have calculated.

  5. #5
    Valued Forum Contributor
    Join Date
    04-11-2006
    MS-Off Ver
    2007
    Posts
    438

    Re: Change Static Range of Formula to Dynamic Range

    So, my number of rows will always change, I assuming that the code will work no matter how many rows there are automatically?

    What I want to do with your code is to insert it into the middle of a very large module. I want the user to run the module and, without any input, have the code know to stop at the last row of data, whatever row that may be on that given day.

    I think you have it that way, but just want to be sure.


    Thanks

  6. #6
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Change Static Range of Formula to Dynamic Range

    Yes that is correct.

  7. #7
    Valued Forum Contributor
    Join Date
    04-11-2006
    MS-Off Ver
    2007
    Posts
    438

    Thumbs up Re: Change Static Range of Formula to Dynamic Range

    Awesome!

    Again, thanks much!
    Last edited by duugg; 01-24-2014 at 10:18 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Dynamic Range while adding static single row
    By bpmcnary in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-08-2013, 04:14 PM
  2. Dynamic Print Area converting to Static range
    By bnl552 in forum Excel General
    Replies: 1
    Last Post: 06-15-2012, 01:14 PM
  3. Turn static RANGE to dynamic
    By Barmoley in forum Excel General
    Replies: 7
    Last Post: 11-14-2010, 04:33 PM
  4. copy data from dynamic range to static range
    By barkarlo in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-16-2009, 02:26 PM
  5. Dynamic data, static range, not updating.
    By Mike K in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 06-08-2006, 12:10 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1