+ Reply to Thread
Results 1 to 6 of 6

How to change the font size based on value of the cell?

  1. #1
    Forum Contributor
    Join Date
    05-02-2013
    Location
    Indiana
    MS-Off Ver
    Microsoft 365 (Subscription)
    Posts
    192

    How to change the font size based on value of the cell?

    Hello,

    I would like to change the font size of cell C4 to 22, if the content of cell C4 is numeric and 16 if the content is a text. I have written a macro to do this; however, I would like to make it automatically change any time the content of cell C4 changes. Currently, I have a button to click to run the macro. The VBA checks cell C4 and changes the font size accordingly. How can I program the macro to recognize when cell C4 changes and apply these conditions automatically? Is there a way to do it without VBA? I do not think that conditional formatting will work.

    Please Login or Register  to view this content.
    Thank you for your help!

    redsab
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    03-28-2013
    Location
    *
    MS-Off Ver
    Excel 2010
    Posts
    226

    Re: How to change the font size based on value of the cell?

    Please Login or Register  to view this content.
    Give Feedback and Click(*)

  3. #3
    Forum Contributor
    Join Date
    01-03-2013
    Location
    Aberdeen, Scotland
    MS-Off Ver
    Excel 2007
    Posts
    163

    Re: How to change the font size based on value of the cell?

    Try this:

    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    05-02-2013
    Location
    Indiana
    MS-Off Ver
    Microsoft 365 (Subscription)
    Posts
    192

    Re: How to change the font size based on value of the cell?

    Sbarro79, Thank you for your input. Your code worked perfectly! However, when I tried to add the code to my real world project, I could not get it to work. Could you taking a look at it and see if you can find out my problem. I have included my spread sheet.

    Text value:
    Go to worksheet Sheet1 and choose Product1 from the drop down list in cell D9. Go to worksheet PA_Running_Sheet_A. In cell D11 you should see the text "2,359/2,302" without the quotes. The value of this cell is a text value. Therefore, it should reduce the font size to 16. But the font size remains at 22. I enter the code nearly identical the way you gave it to me.

    Numberic value:
    Go to worksheet Sheet1 and choose Product3 from the drop down list in cell D9. Go to worksheet PA_Running_Sheet_A. In cell D11 you should see the number 9,204. The value of this cell is a numeric value. Therefore, it should increase the font size to 22.

    In the VBA editor I entered the Worksheet_Change subroutine in the PA_Running_Sheet_A worksheet area. Is that correct? Thank you so much for your help!

    redsab
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    01-03-2013
    Location
    Aberdeen, Scotland
    MS-Off Ver
    Excel 2007
    Posts
    163

    Re: How to change the font size based on value of the cell?

    Hi redsab

    I looked into your file and I think I know what's the problem - cell D11 value is modified by formula (which I didn't know about initially) and that's why the code doesn't work. Worksheet_Change event is triggered when cell is changed manually, or by VBA code.
    Meanwhile I tried to do something with this and here it is (add this code to worksheet Sheet1 module)

    Please Login or Register  to view this content.
    I hope this is, what you're looking for

  6. #6
    Forum Contributor
    Join Date
    05-02-2013
    Location
    Indiana
    MS-Off Ver
    Microsoft 365 (Subscription)
    Posts
    192

    Re: How to change the font size based on value of the cell?

    Sbarro79,
    Yes! That did the trick! Thanks for all your help. I know that may have seemed a little petty, but I am all about detail. Your the best!

    redsab

+ 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: 6
    Last Post: 07-18-2013, 04:16 AM
  2. [SOLVED] Change default font and font size on COMMENTS in cells
    By Thistledown in forum Excel General
    Replies: 4
    Last Post: 11-23-2012, 09:26 AM
  3. [SOLVED] Change font size in row based on cell value within specific column
    By Fullalove in forum Excel General
    Replies: 14
    Last Post: 06-27-2012, 05:51 PM
  4. Change font size based on a Cell Value
    By kalyanverma in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-21-2008, 11:39 AM
  5. Cell value specific font size change
    By Geoff C in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-06-2006, 05:15 AM

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