+ Reply to Thread
Results 1 to 6 of 6

Using cell value to define range

  1. #1
    Registered User
    Join Date
    02-15-2007
    Posts
    1

    Using cell value to define range

    I can't find an answer after searching forums. I'm doing some analysis that uses an array formula. However, I need to change the defined range every time I add new data to the working sheet because my different datasets have different number of rows each time. The format of the formula is:

    =SUM(($G$2:$G$4628>$AC$2)*($A$2:$A$4628=T2)*($H$2:$H$4628))

    I have to enter the exact range every time so that I don't get the #N/A error. I have preformatted to calculate the number of cells with values, this is in cell s41. My questions...

    Is there a way to define part of a range using a cell value? (e.g. something like $G$2:$G$CellValueS41)

    Or, can I have Excel skip over the #N/A in the columns so it will just calculate based on cells with numbers? I'm not an advanced user so not into programming etc.

    Any ideas welcome.

    Thanks,

    JimBob

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    Try building dynamic defined names that will react to the amount of data available. You can then use the same formula that references the names.

    Insert, name, define
    arng, =OFFSET(Sheet1!$A$2,0,0,COUNTA(Sheet1!$A:$A),1)
    grng, =OFFSET(arng,0,6)
    hrng, =OFFSET(arng,0,7)

    and your formula becomes

    =SUM((grng>$AC$2)*(arng=T2)*(hrng))

    Depending on the data in column A, your name definition formula may have to change....

    hth

    rylo

  3. #3
    Registered User
    Join Date
    01-13-2007
    Posts
    71
    rylo,

    i've tried to add a dynamic name reference but i don't know why the reference isn't working.
    do you know why would this happen?
    i entered in insert>name>define> the name of the reference i wanted and in the reference field i wrote "=offset(sheets1!$C$4;0;0;COUNTA(SHEETS1!$C:$C);0)
    What am i doing wrong here??

    thx

  4. #4
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Think you need to change the 0 at the end to one. You can't have zero columns

    http://www.contextures.com/xlNames01.html#Dynamic

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  5. #5
    Registered User
    Join Date
    01-13-2007
    Posts
    71
    Iam the real vba noob here!!! ehhehehe

    thx!!

  6. #6
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    No problem

    VBA Noob

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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