+ Reply to Thread
Results 1 to 3 of 3

Function and CASE

  1. #1
    Forum Contributor
    Join Date
    03-11-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2016 (among others!)
    Posts
    331

    Function and CASE

    I've been working round this for a while but decided to finally tackle it head on as it's becoming a regular pain.

    I have a lot of customs functions that call upon others to get standing data. So for instance one formula works out the tax due on income. But rather than have the variables there they are in a separate function to make life easier to update it. One of these is for dates.

    This is what it looks like now.

    Please Login or Register  to view this content.
    In cell it is =update_dates("tax_year")

    And this works. But I can't help thinking I'm missing something. Like I shouldn't need to use the case statement - I should be able to go directly from the variable "required_date" to the answer, even more so in this example as the defined constants and the names passed are the same. But I've never been able to get it to work. I would guess something like update_dates=required_date - but clearly that just gives the text that was passed to it.

    Anyone any ideas? I've a feeling it's quite straightforward but I've missed it. Thanks in advance.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,465

    Re: Function and CASE

    Why don't you use Named Ranges for those dates? Then the values are external to the code ... And readily accessible on the worksheet.

    I may be missing something in your logic though.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Contributor
    Join Date
    03-11-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2016 (among others!)
    Posts
    331

    Re: Function and CASE

    NUts! My reply vanished. SO the shorter version. Basically the constants might be used in 40 spreadsheets and I can't use a link to any external workbooks. SO the best way to sort it (and update it considering the sheets are protected) was thought to be via the VBA code.

    As another for instance there is a formula =DC("what_rate_you_want","what_year"). As each year has about 60 rates it uses arrays instead, matching the text against the rate list to give an index. That index is then used in another array to give the magic number.

    But this date one is simpler (thankfully). Just can't help thinking I'm missing something with it.

+ 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. Need help to change multiple criteria from if function to Case function.
    By indkitty in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-29-2012, 10:42 PM
  2. Case function
    By Rage in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-05-2011, 08:32 AM
  3. Does Any Excel function can help this case?
    By AlanTang in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-06-2009, 10:08 AM
  4. Case function substitute
    By Mariano in forum Excel General
    Replies: 2
    Last Post: 01-06-2006, 12:20 PM
  5. [SOLVED] Case function
    By Al in forum Excel General
    Replies: 5
    Last Post: 08-23-2005, 04: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