Results 1 to 2 of 2

Thread: Select A Range Dynamically Based On Count Of Values

  1. #1
    Junior Member
    Join Date
    Jul 2013
    Posts
    4
    Rep Power
    0

    Select A Range Dynamically Based On Count Of Values

    Hi,

    I am trying to select a code using variables. Since the range is dynamic, I am using a counta function to determine the no of rows. Below is the code I have used, but its not correct.

    Code:
    Dim Nmbr As Integer
        Nmbr = Range("R1").Value
        Range("R1") = WorksheetFunction.CountA(Range("S:S"))
        Range("R2").Select
        Range("R2").Resize(Nmbr, 6).Select
    Thanks for your help!
    Last edited by Excel Fox; 02-19-2014 at 07:05 PM. Reason: Code Tags added

  2. #2
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,402
    Rep Power
    10
    Try this

    Code:
        Dim Nmbr As Integer
        Range("R1") = WorksheetFunction.CountA(Range("S:S"))
        Nmbr = Range("R1").Value
        Range("R2").Resize(Nmbr, 6).Select
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

Similar Threads

  1. Convert Series into Range with specified count
    By ayazgreat in forum Excel Help
    Replies: 3
    Last Post: 11-09-2013, 01:41 PM
  2. IF STATEMENT BASED ON EQUAL VALUES IN RANGE
    By mrmmickle1 in forum Excel Help
    Replies: 3
    Last Post: 09-09-2013, 05:54 PM
  3. Replies: 2
    Last Post: 06-24-2013, 07:40 PM
  4. Change Display Range Based On Change of Dropdown Values
    By rich_cirillo in forum Excel Help
    Replies: 2
    Last Post: 03-29-2013, 04:58 AM
  5. Count consecutive value in a range using formula
    By LalitPandey87 in forum Excel Help
    Replies: 6
    Last Post: 11-12-2012, 05:23 PM

Posting Permissions

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