+ Reply to Thread
Results 1 to 5 of 5

Problems in changing font format of the current cell

  1. #1
    Registered User
    Join Date
    04-24-2012
    Location
    Venezuela
    MS-Off Ver
    Excel 2010
    Posts
    9

    Problems in changing font format of the current cell

    Hi Guys!

    I've made a function (code shown below) that with a text input returns a UPC code, this code with proper font can be read as Barcode...

    The thing is that I don't find the way to change the font name and size of the cell where the function is running. Here's the code


    Please Login or Register  to view this content.
    The code works beautifully but the last three lines are supposed to automatically modify the font parameters so I don't have to do it mannually...

    I'm getting to the conclusion that maybe a function can't support this behaviour and maybe I've to figure it out by another mean

    Thanks in advance!

  2. #2
    Forum Expert
    Join Date
    03-20-2015
    Location
    Primarily UK, sometimes NL (COVID allowing)
    MS-Off Ver
    Work: Office 365 / Home: Office 2010
    Posts
    2,402

    Re: Problems in changing font format of the current cell

    In theory, a function can't format a cell (see here).

    There are ways around this, of varying complexity and danger of crashing Excel. Try 'excel change font user defined function' in your favourite search engine and look at a few of the links found (I can't post the most useful ones I've seen, as they're on competing forums to this one, so would break Forum Rule 13 - sorry).
    Regards,
    Aardigspook

    Recently moved house, internationally, during COVID (!) so am a bit busy and may not reply quickly. Sorry - it's not personal - I will reply eventually.
    If your problem is solved, please go to 'Thread Tools' above your first post and 'Mark this Thread as Solved'.
    If you use commas as your decimal separator (1,23 instead of 1.23) then please replace commas with semi-colons in your formulae.
    You don't need to give me rep if I helped, but a thank-you is nice.

  3. #3
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    1,888

    Re: Problems in changing font format of the current cell

    The essence of the function is that it must contain a command (-s) that assigns some value to the function's name, that will result from that function. Then we have the name of the function on the left side of the equation and the result of this function on the right.
    The function is a passive construct and the sub-routine is active.
    The active / executive commands "not very" fall within the scope of the function.

    What happens if the VLookup function returns an error ? Did you check it ?

  4. #4
    Registered User
    Join Date
    04-24-2012
    Location
    Venezuela
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Problems in changing font format of the current cell

    Thanks both for the information... I'll made changes using your comments as guides.

    Aardigspook: I tought so what I was still trying

    Porucha vevrku: I've check it, but I'm gonna recheck and put some error handlers.

    Regards

  5. #5
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    1,888

    Re: Problems in changing font format of the current cell

    Ps.:
    Declare all variables/constants with their type, this is more secure for the code.
    In some places you can shorten the code, eg.: ".Range(.Range("$b$2"), .Range("$c$108"))" = ".Range("$b$2:$c$108"))". etc.
    Instead of direct reference to the sheet functions, you can use the 'Evaluate' method, it's easier, e.g. to control error handling.

+ 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] Changing Cell Value format as desired while saving the file in the current directory
    By Ravana in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-24-2017, 04:25 PM
  2. having problems changing the date format
    By oto45 in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 12-22-2015, 04:58 AM
  3. [SOLVED] Problems with changing date format
    By GIS2013 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 03-19-2014, 10:50 AM
  4. [SOLVED] How to force a user to use red font/lock cell only for font format?
    By ThomasCarter in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-28-2012, 08:48 AM
  5. Changing font color in sum cell
    By Sindee123 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-09-2012, 12:31 PM
  6. Conditional format for changing font colors using VBA
    By marc5354 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-12-2010, 04:32 PM
  7. [SOLVED] How do I format spreadsheet w/o changing font size?
    By Amber W. in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 03-27-2006, 12: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