+ Reply to Thread
Results 1 to 7 of 7

Formula to compare different values in different columns based on user input

  1. #1
    Registered User
    Join Date
    07-17-2007
    Posts
    15

    Formula to compare different values in different columns based on user input

    Hello,

    Normally, when I want to compare the difference as a percentage between 2 columns, A (old price) and B (new price), I use a simple formula B/A-1. This gives me the price increase as a percentage between B and A.

    My problem is that I have 4 columns (with new prices) and 10 columns (with old prices) and I would like to compare any 1 of the 4 columns compared to any 1 of the 10 columns.

    Is there a formula, where I can enter the letter or number of the columns into 2 different cells, it can calculate the difference as a percentage?

    The heat is melting my brain and I cannot work it out.

    I was thinking something like this, if in cell A1 I enter 4 and in cell B2 I enter 10, the formula calculates column4/column10-1.

    Any help very much welcomed.

    Thank you!

  2. #2
    Forum Expert sourabhg98's Avatar
    Join Date
    10-22-2014
    Location
    New Delhi, India
    MS-Off Ver
    Excel 2007, 2013
    Posts
    1,899

    Re: Formula to compare different values in different columns based on user input

    Maybe something like this--
    Attached Files Attached Files
    Happy to Help

    How to upload excel workbooks at this forum - http://www.excelforum.com/the-water-...his-forum.html

    "I don't get things easily, so please be precise and elaborate"

    If someone's post has helped you, thank by clicking on "Add Reputation" below the post.
    If your query is resolved please mark the thread as "Solved" from the "Thread Tools" above.

    Sourabh

  3. #3
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: Formula to compare different values in different columns based on user input

    This "A1 I enter 4 and in cell B2 I enter 10, the formula calculates column4/column10-1 " you can easily achiewe with INDIRECT or OFFSET

    so lets say your first 4 are new A2:D2, then 10 old E2:N2
    in O2 you write 2 to use B2 and in P2 3 to use G2:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Best Regards,

    Kaper

  4. #4
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Formula to compare different values in different columns based on user input

    Assuming your data is in Row 3 from A3 to J3 (column 10)

    =INDEX(A3:A10, B2)/INDEX(A3:A10, A1) -1
    I reversed what you said in last post since you originally said B/A

    Does that work for you?
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  5. #5
    Forum Expert sourabhg98's Avatar
    Join Date
    10-22-2014
    Location
    New Delhi, India
    MS-Off Ver
    Excel 2007, 2013
    Posts
    1,899

    Re: Formula to compare different values in different columns based on user input

    Slight changes--
    With conditional formatting which would automatically highlight the value selected with blue color....according to the column number typed..
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    07-17-2007
    Posts
    15

    Re: Formula to compare different values in different columns based on user input

    Hello guys, many thanks for the replies. I've been on vacation but strangely I didn't receive any notifications regarding your replies. I will give them all a try and update you all.

    Again, I am truly grateful for those who have tried to help me.

    Ciao!

  7. #7
    Registered User
    Join Date
    07-17-2007
    Posts
    15

    Re: Formula to compare different values in different columns based on user input

    Quote Originally Posted by Kaper View Post
    This "A1 I enter 4 and in cell B2 I enter 10, the formula calculates column4/column10-1 " you can easily achiewe with INDIRECT or OFFSET

    so lets say your first 4 are new A2:D2, then 10 old E2:N2
    in O2 you write 2 to use B2 and in P2 3 to use G2:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Hello everyone,

    Sorry for the late reply. This one worked perfectly. I modified it slightly so that you only need to enter the 2 and the 3 (from the above example) in 2 fixed cells (using $O$2 and $P$2 - another tip I learnt from this fantastic forum) at the top of the sheet (because there are about 800 rows) just to make things simpler.

    Many thanks also to sourabhg98 and ChemistB for taking the time and effort to help me.

    Enjoy your day!


+ 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] Looking for a Macro to Unhide Columns based on a User's Input
    By Candlelight in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 04-04-2014, 08:37 AM
  2. [SOLVED] Averaging a user input defined range based on values in columns
    By smit.etha in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 02-14-2014, 02:21 AM
  3. [SOLVED] Adding X Columns for user input based on value of one cell
    By reluctantresearch in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 09-25-2013, 01:50 PM
  4. [SOLVED]Hide Rows and Columns Based on User Input
    By thesteve in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-31-2013, 01:32 PM
  5. Automatic Formula Input Based on User Input Using a Macro
    By Drayloc in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-03-2012, 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