+ Reply to Thread
Results 1 to 3 of 3

How to apply similar formula to all cells in a column?

  1. #1
    Registered User
    Join Date
    04-02-2009
    Location
    Winnipeg, Canada
    MS-Off Ver
    Excel 2000
    Posts
    1

    How to apply similar formula to all cells in a column?

    I have three columns in an excel sheet, the first column has a dollar value, the second is the tax on that dollar value and the third is the vendor to which the dollar amount was paid to. Only certain vendors, however are tax exempt. What I would like to do is enter the dollar value, select my vendor and have the tax calculated. On a separate sheet, I've set up a vendors list along with their tax exemption status, yes or no. This allows me to have a pull down list of vendors using the data validation method to select my vendor. The dollar amount is entered manually and for the tax calculation I use the following formula
    =IF(VLOOKUP(C3, Sheet2!A3:B5, 2, FALSE) = "yes", A3*0.05, " ")
    The C column is the vendor entry
    Sheet2 is the vendor list
    The A column is the dollar amount entry

    For this particular row, it takes the vendor(C3), locates it in the A column of my vendor list (Sheet2!) and returns a yes or no from the B column. If it's "yes" then it calculates a 5% tax on the dollar amount(A3), if not it leaves it blank.

    For the next row, the formula should look like this
    =IF(VLOOKUP(C4, Sheet2!A3:B5, 2, FALSE) = "yes", A4*0.05, " ")
    only the vendor(C4) and dollar amount(A4) change not the lookup table.

    However, if I click on the bottom right corner of the first cell in the tax column and extend it to the next cell down so as to copy the formula it ends up with this
    =IF(VLOOKUP(C4, Sheet2!A4:B6, 2, FALSE) = "yes", A4*0.05, " ")
    You will notice that the lookup tables parameters have changed from A3:B5 to A4:B6.

    How can I apply the same formula to all cells in a column and control which variables are affected?

  2. #2
    Forum Contributor
    Join Date
    03-12-2009
    Location
    Calgary, Canada
    MS-Off Ver
    Excel 365
    Posts
    236

    Re: How to apply similar formula to all cells in a column?

    This is the difference between absolute referencing and relative referencing. You want relative referencing for the lookup value but you want the lookup table to be absolutely referenced. To accomplish absolute referencing use "$" for example =IF(VLOOKUP(C4, Sheet2!$A$3:$B$5, 2, FALSE) = "yes", A4*0.05, " "). You can do partial referencing where if you intend to copy a formula across columns but you don't want the reference column to change, use $A1, copying down will still change the row here. The $ stops the character after it from changing when copying cells.
    If you can't figure out how a formula works, try stepping through it using "Evaluate Formula" in the Formula Auditing menu item in the tools menu!

    If you want to see where your code went wrong, try stepping through it by clicking in the code and pressing F8 and watch as the magic happens!


    If you are happy with any of the results, please add to the contributor's reputation by clicking the star icon.

  3. #3
    Forum Contributor
    Join Date
    03-31-2009
    Location
    Childers QLD, Australia
    MS-Off Ver
    Excel 2003, 2007 & 2013
    Posts
    128

    Re: How to apply similar formula to all cells in a column?

    Hi,

    To do what you want you need to lock the refrence cells using $.

    sample =IF(VLOOKUP(C3, Sheet2!$A$3:$B$5, 2, FALSE) = "yes", A3*0.05, " ")

    When you fill down the ref on sheet2 will not change.

    Cheers

    Tony

+ 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