+ Reply to Thread
Results 1 to 8 of 8

Dynamically change formula range

  1. #1
    Registered User
    Join Date
    08-28-2018
    Location
    Washington
    MS-Off Ver
    2010
    Posts
    3

    Dynamically change formula range

    Hi All,

    I have the following data
    A B C D E F G H I J K L M N O P
    D A A D D D
    D D D D D D D D
    D A
    D D D D D D D D D A


    I have to compare the value in column A with the rest of the columns in the same row. If any of the values from B to K is different than the value in A, then I have to display "Incon" in result. If all the values from B to K is same as that in A, then I have to display "Con" in result. I am testing out the following formula =IF(OR(C1<>D1:F1),"Incon","Con") but when there are spaces in some columns the formula is not working. Can we dynamically set the range (end point) so that my formula won't compare the value in A with spaces?

    Thanks
    Luke.

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,926

    Re: Dynamically change formula range

    Hi, welcome to the forum

    Try this, copied down...
    =IF(COUNTIF(B1:J1,A1)=COUNTA(B1:J1), "con","incon")
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Registered User
    Join Date
    08-28-2018
    Location
    Washington
    MS-Off Ver
    2010
    Posts
    3

    Re: Dynamically change formula range

    That worked. Thanks. But just for future reference, is there any way to dynamically change the end column name when we copy down a formula?

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,926

    Re: Dynamically change formula range

    Quote Originally Posted by 119luke View Post
    That worked. Thanks. But just for future reference, is there any way to dynamically change the end column name when we copy down a formula?
    Not sure I understand what you mean?
    Do you want the J to be dynamic?

  5. #5
    Registered User
    Join Date
    08-28-2018
    Location
    Washington
    MS-Off Ver
    2010
    Posts
    3
    Quote Originally Posted by FDibbins View Post
    Not sure I understand what you mean?
    Do you want the J to be dynamic?
    Yes. That's what I meant. Is it possible?

  6. #6
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,926

    Re: Dynamically change formula range

    =IF(COUNTIF(B1:J1,A1)=COUNTA(B1:J1), "con","incon")
    Why would you need to make this dynamic? If you take the range up to the cell just before the formula, it will work, no matter how many entries you have

  7. #7
    Forum Contributor
    Join Date
    08-14-2018
    Location
    Hanoi, Vietnam
    MS-Off Ver
    2016
    Posts
    118

    Re: Dynamically change formula range

    Hi 119luke,
    Plz try this
    Q1=IF(SUMPRODUCT((A1=OFFSET($B1,,,,LOOKUP(2,1/(TRIM(CLEAN(SUBSTITUTE(B1:P1," ","")))<>""),ROW($1:$100))))*1)=LOOKUP(2,1/(TRIM(CLEAN(SUBSTITUTE(B1:P1," ","")))<>""),ROW($1:$100)),"con","incon")
    Last edited by congnt92; 08-29-2018 at 03:37 AM.

  8. #8
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,926

    Re: Dynamically change formula range

    congnt92 nice formula

    BUT, you have already defined a range there (B1:P1), so, depending on what else may be within that range, you could just use that range as is, in my suggested formula.

    No matter how you look at this, you need to define a range somewhere, somehow.

+ 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. [SOLVED] Expand Defined Name Range Horizontally to Dynamically Change Chart with new data
    By machl22 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-20-2017, 12:14 PM
  2. [SOLVED] Can a Chart dynamically change it range based on a cells value?
    By Bobbbo in forum Excel Charting & Pivots
    Replies: 7
    Last Post: 09-09-2017, 03:11 PM
  3. SOLVED-Dynamically change size/range of x axis of chart
    By helpme858 in forum Excel General
    Replies: 2
    Last Post: 08-07-2017, 12:20 PM
  4. Replies: 3
    Last Post: 06-28-2016, 04:24 AM
  5. Change the range in x axis dynamically for line chart
    By dimwit in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 06-27-2013, 05:23 AM
  6. How to change Pivot Range dynamically(Macro)
    By leninbabu in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-09-2009, 06:38 AM
  7. Replies: 1
    Last Post: 01-09-2006, 05:15 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