+ Reply to Thread
Results 1 to 7 of 7

Auto inserting a formula when using Data Validation list

  1. #1
    Registered User
    Join Date
    01-15-2019
    Location
    uk
    MS-Off Ver
    Microsoft 365
    Posts
    21

    Auto inserting a formula when using Data Validation list

    Hi,
    I am hoping someone can help.

    I am working on a spreadsheet where I would like to be able to make a selection from a drop down list and auto insert a formula relating to the selection made.

    Working on the example attached I would like to be able make a selection from the drop down list under "TYPE", which will auto fill "RATE" and auto insert a formula into the "COST" boxes (Data on RATES tab).
    Depending on the selection under "TYPE" would depend on the formula inserted under "COST".

    Formula to be inserted:
    For selections 1M, 2M and OUT I would like to formula to be RATE ÷ 60 x TIME.
    For selections COOK and MAT I would like the formula to be RATE x TIME.

    I would like the formula row to auto change to the row that it is being inserted on, so it is unique to the figure put in TIME on that row.

    Currently I have it inserting the formula as text not a formula and cannot get it to change to suit the row it is on.

    I hope that makes sense and what I am asking is possible.

    Thanks
    Attached Files Attached Files

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    91,031

    Re: Auto inserting a formula when using Data Validation list

    Administrative Note:

    Members will tailor the solutions they offer to the version of Office (Excel) that you have. Please check that your forum profile is up-to-date in this respect. If you aren't sure, in Excel go to File | Account and report what it says below the MS logo at the top of that page. If your version is for Mac, please also state this. Thanks.

    Try this:

    =IF(OR(H4="COOK",H4="MAT"),I4*K4,I4/60*K4)
    Last edited by AliGW; 01-06-2022 at 12:39 PM.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    01-15-2019
    Location
    uk
    MS-Off Ver
    Microsoft 365
    Posts
    21

    Re: Auto inserting a formula when using Data Validation list

    Thank you for the reply AliGW

    It has worked nicely.

    One further question though, if you don't mind,

    I am going to keep expanding the drop down table,
    Is it possible to attach the formula to the drop down menu table at all?
    Just so I don't have to keep updating the formula with the new table inputs.

    Thank you
    Attached Files Attached Files

  4. #4
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,411

    Re: Auto inserting a formula when using Data Validation list

    if you use 'structured tables' any formula expand as you add extra rows - do not have blank rows at the foot of the table.
    Torachan,

    Mission statement; Promote the use of Tables, Outlaw the use of 'merged cells' and 'RowSource'.

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    91,031

    Re: Auto inserting a formula when using Data Validation list

    Why are you using the outdated .xls format? You should save files with an .xlsx suffix.

    Attached is a copy with your tablle converted to a structured table (see what torachan said above).

    If you structure your formulae correctly (i.e. with the correct relative and absolute references), then you can drag them down. No need to copy to every new line!!!
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    01-15-2019
    Location
    uk
    MS-Off Ver
    Microsoft 365
    Posts
    21

    Re: Auto inserting a formula when using Data Validation list

    Thank you Both,

    Sorry I wasn't very clear in my last reply.
    I managed to drag the formula down ok.

    My problem is I want to keep adding parts to the RATES tab for my drop down list, e.g SPEC which would also need the formula =I4*K4.
    So I know I can add ,H4="SPEC" to the formula e.g =IF(OR(H4="COOK",H4="MAT",H4="SPEC"),I4*K4,I4/60*K4)

    But over time this formula would keep growing, so I was wondering if there was a neater method?

    Hope that makes sense.


    Regarding the format, my apologies I am new to all this and didn't know the difference.

    Thank you and have a great weekend.

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    91,031

    Re: Auto inserting a formula when using Data Validation list

    I think you need to create lookup tables and think ahead a bit.

    Tell us what all the possible combinations are and someone will help you create a lookup table that the formula can use. Then it's a case of maintaining the table rather than the formula.

    For example, you could create this table:

    AliGW on MS365 Insider (Windows) 64 bit

    A
    B
    C
    1
    Rates
    2
    Divisor
    3
    1M
    10
    60
    4
    2M
    7
    60
    5
    OUT
    5
    60
    6
    COOK
    4.5
    1
    7
    MAT
    2.5
    1
    Sheet: Rates

    then use this in H4:

    =E4/INDEX(Rates!$C$3:$C$7,MATCH([@TYPE],Rates!$A$3:$A$7,0))*G4
    Last edited by AliGW; 01-07-2022 at 09:38 AM.

+ 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] Auto Complete data validation list
    By YasserKhalil in forum Excel Programming / VBA / Macros
    Replies: 38
    Last Post: 12-20-2014, 05:02 AM
  2. Data Validation list that will Auto drop down.
    By kod1ak in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-15-2014, 08:34 PM
  3. [SOLVED] Auto Complete Data Validation List
    By joebell in forum Excel General
    Replies: 4
    Last Post: 07-24-2014, 12:34 AM
  4. Auto-Generate List from reference cells based on data validation list selection
    By BoundCustomDesign in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 05-13-2014, 11:06 AM
  5. [SOLVED] Auto scroll down data validation list
    By texastek76@yahoo.com in forum Excel General
    Replies: 6
    Last Post: 09-20-2012, 11:25 AM
  6. Auto complete for data validation list
    By KevinThomas in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-26-2010, 10:44 AM
  7. [SOLVED] Inserting rows with Data, Formula's and Validation
    By Doug Manning in forum Excel General
    Replies: 0
    Last Post: 09-16-2005, 08:05 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