+ Reply to Thread
Results 1 to 5 of 5

Set cell format from a UDF that returns a date

  1. #1
    Forum Contributor
    Join Date
    10-02-2013
    Location
    Harrisburg, PA
    MS-Off Ver
    Office 365 MSO (16.0.10730.20264) 32-bit
    Posts
    160

    Set cell format from a UDF that returns a date

    Hi All.

    I have written a simple UDF that converts calendar date to my company's Fiscal date. Fiscal date = calendar date - 3 months. I could use Edate(A1,-3) but then I would need to format the cell.

    I would like the UDF to do the conversion return the date and then set the format. It does not seem like I can format the select cell in the UDF?

    Please Login or Register  to view this content.

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,258

    Re: Set cell format from a UDF that returns a date

    You can't do that in a UDF. It can really only return a value to the cell.
    Remember what the dormouse said
    Feed your head

  3. #3
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Set cell format from a UDF that returns a date

    To get the functionality you require, I'd use a Worksheet_Change event to trigger on that formula.

    Please Login or Register  to view this content.
    Make Mom proud: Add to my reputation if I helped out!

    Make the Moderators happy: Mark the Thread as Solved if your question was answered!

  4. #4
    Forum Contributor
    Join Date
    10-02-2013
    Location
    Harrisburg, PA
    MS-Off Ver
    Office 365 MSO (16.0.10730.20264) 32-bit
    Posts
    160

    Re: Set cell format from a UDF that returns a date

    Thanks. I did not think It could be done. Also, I did not want to tie it to a specific workbook - don't want to use Worksheet Change(). I will just go with the EDATE(A1,-3) and have them do a custom format.

  5. #5
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,258

    Re: Set cell format from a UDF that returns a date

    It's not strictly true to say that it can't be done - there are a couple of convoluted options to allow UDFs to do pretty much anything, but they're OTT for this, I would suggest.

+ 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. Replies: 7
    Last Post: 07-14-2017, 12:04 PM
  2. Cell returns value if another cell fits within a date range
    By kellyla88 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-04-2014, 07:19 AM
  3. Replies: 1
    Last Post: 11-01-2012, 10:37 AM
  4. [SOLVED] Conditional format a cell (contaning a formula) that only returns a positive value
    By Thistledown in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-02-2012, 04:17 AM
  5. Conditional format a cell when the formula returns False
    By eddienole in forum Excel General
    Replies: 1
    Last Post: 05-16-2012, 01:35 PM
  6. Date Value Returns a Number in Cell
    By realniceguy5000 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-13-2009, 01:42 PM
  7. Function: Cell (format) only returns G when value is Text
    By Dave32 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-07-2008, 05:56 AM
  8. Replies: 4
    Last Post: 08-28-2007, 05:45 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