+ Reply to Thread
Results 1 to 14 of 14

keep cell range constant when deleting rows

  1. #1
    Registered User
    Join Date
    08-02-2009
    Location
    Lancashire, England
    MS-Off Ver
    Excel 2007
    Posts
    84

    Thumbs up keep cell range constant when deleting rows

    Hi all

    This will probably be really simple but thanks in advance for your time and help.

    i have a COUNTIF formula with a cell range for example P5:P250, however, i need to delete rows from within this range, when i do this the range drops, eg P5:P249

    Is there a way to keep the defined range constant, i seem to recall something about dollar symbols $ but have tried adding these however no joy.

    Thanks

    Si
    Last edited by Si902; 06-24-2010 at 10:50 AM.

  2. #2
    Forum Contributor johnjohns's Avatar
    Join Date
    11-19-2007
    Location
    Dubai, UAE
    MS-Off Ver
    2003 and 2007
    Posts
    526

    Re: keep cell range constant when deleting rows

    I hope INDIRECT command will help.

    rgds

    johnjohns

  3. #3
    Registered User
    Join Date
    08-02-2009
    Location
    Lancashire, England
    MS-Off Ver
    Excel 2007
    Posts
    84

    Re: keep cell range constant when deleting rows

    Hi john

    Thanks, do you mean just replace COUNTIF with INDIRECT ?

    Ta

    Si

  4. #4
    Forum Contributor johnjohns's Avatar
    Join Date
    11-19-2007
    Location
    Dubai, UAE
    MS-Off Ver
    2003 and 2007
    Posts
    526

    Re: keep cell range constant when deleting rows

    see the attachment

    rgds

    johnjohns
    Attached Files Attached Files

  5. #5
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: keep cell range constant when deleting rows

    If you prefer to avoid Volatility use INDEX rather than INDIRECT

    =COUNTIF(INDEX(P:P,5):INDEX(P:P,250),"apple")

    (assumes column P is never removed in it's entirety)

  6. #6
    Registered User
    Join Date
    08-02-2009
    Location
    Lancashire, England
    MS-Off Ver
    Excel 2007
    Posts
    84

    Re: keep cell range constant when deleting rows

    Thanks for that John, but dont think its quite what i'm after, i probably didnt describe it well enough, here's another try

    i have a sheet pulling data from other worksheets within the same workbook, the formula im using is COUNTIF(A!P5:P250,"Y") this returns the number of Y on sheet A in that cell range, however i need to delete rows on sheet A but need the cell range on the data sheet to remain the same.

    Ta

  7. #7
    Registered User
    Join Date
    08-02-2009
    Location
    Lancashire, England
    MS-Off Ver
    Excel 2007
    Posts
    84

    Re: keep cell range constant when deleting rows

    Thanks DonkeyOte

    Will try.

    Si

  8. #8
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: keep cell range constant when deleting rows

    There's no issue with johnjohns approach other than the fact INDIRECT is Volatile which may / may not be an issue for you
    (see link in sig. for more info. re: Volatility)

    =COUNTIF(INDIRECT("'A'!P5:P250"),"Y")

    will work equally as well as:

    =COUNTIF(INDEX('A'!P:P,5):INDEX('A'!P:P,250),"Y")

    (INDIRECT is pref. in such instances where intention is to physically delete & replace 'A' sheet - if not I tend to avoid it)

  9. #9
    Registered User
    Join Date
    08-02-2009
    Location
    Lancashire, England
    MS-Off Ver
    Excel 2007
    Posts
    84

    Re: keep cell range constant when deleting rows

    Have tried that DonkeyOte however returns #NAME

    I added m sheet name A into the formula though

    =COUNTIF(INDEX(A!P:P5,5);INDEX(P:P,250),"Y"

    Any suggestions?

  10. #10
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: keep cell range constant when deleting rows

    see the prior post for working examples of both approaches...

  11. #11
    Registered User
    Join Date
    08-02-2009
    Location
    Lancashire, England
    MS-Off Ver
    Excel 2007
    Posts
    84

    Re: keep cell range constant when deleting rows

    Just seen your other reply

    Will try

  12. #12
    Registered User
    Join Date
    08-02-2009
    Location
    Lancashire, England
    MS-Off Ver
    Excel 2007
    Posts
    84

    Re: keep cell range constant when deleting rows

    Neither seem to work

    =COUNTIF(INDIRECT("A'!P5:P250"),"Y" returns #REF!

    =COUNTIF(INDEX('a'!P:P5,5):INDEX('A'!P:P,250),"Y" returns "missing parenthasis" when added following 250)) returns "entered too few arguments" and #NAME?

  13. #13
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: keep cell range constant when deleting rows

    Not to sound like a broken record - use the samples provided (and/or compare the parentheses in my suggestions to those you have tried)

  14. #14
    Registered User
    Join Date
    08-02-2009
    Location
    Lancashire, England
    MS-Off Ver
    Excel 2007
    Posts
    84

    Talking Re: keep cell range constant when deleting rows

    Sorted

    Thanks for that DonkeyOte

    I used the example provided and works a treat, also realised what i had missed out.

    Thanks again

    Si

+ 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