+ Reply to Thread
Results 1 to 4 of 4

Can i make custom function which changes the format of the cell with the formula

  1. #1
    Forum Contributor
    Join Date
    08-15-2015
    Location
    India
    MS-Off Ver
    Office 2016
    Posts
    221

    Can i make custom function which changes the format of the cell with the formula

    Hello friends, am creating a custom function for my sheet,
    Call this function mm2cm, which will convert millimeters to centimeters.

    Now say the value in cell A1 is 50.00 mm and i enter =mm2cm(A1) in cell B1

    The result in B1 is 5,

    i want the value in B1 to show as 5.00 cm

    meaning as if it has been formatted to 0.00 cm

    Can anyone help me with this

    My VBA Code so far is as follows
    Please Login or Register  to view this content.

  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,359

    Re: Can i make custom function which changes the format of the cell with the formula

    In theory, a UDF can't change the formatting of a cell. However, you could just use a Custom Format
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    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
    08-15-2015
    Location
    India
    MS-Off Ver
    Office 2016
    Posts
    221

    Re: Can i make custom function which changes the format of the cell with the formula

    Thanks for your reply, i know i can do that, but was looking to automize the process with the function only

  4. #4
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,704

    Re: Can i make custom function which changes the format of the cell with the formula

    As Trevor says, a function cannot affect the formatting of a cell, so you will have to return a text value with the "cm" tagged on to the end of the number. However, that could affect other calculations elsewhere in the workbook if they rely on the cm value being a number.

    Hope this helps.

    Pete

+ 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] Apply Custom Format Of Cell To A New Cell With Formula Using Its Reference
    By tv69 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-29-2013, 05:58 PM
  2. Change cell format to make Sum function possible
    By ExcelBal in forum Excel General
    Replies: 4
    Last Post: 02-22-2013, 04:19 PM
  3. Custom Cell Format/function automated addition
    By andradejose89 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-07-2012, 04:55 PM
  4. Conveying custom number format to new cell via formula
    By delirium in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-03-2009, 12:36 PM
  5. make a custom Format?
    By Zyphon in forum Excel General
    Replies: 5
    Last Post: 09-20-2007, 08:44 AM
  6. Custom format cells - how to make it say < number
    By liniis in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-16-2006, 07:30 PM
  7. make:Custom Number Format
    By robertjtucker in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-09-2006, 02:35 PM

Tags for this Thread

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