+ Reply to Thread
Results 1 to 2 of 2

Macro for Automatic Font Size Change for Two Different Cell Values

  1. #1
    Registered User
    Join Date
    01-02-2020
    Location
    Owings Mills, MD
    MS-Off Ver
    1911
    Posts
    4

    Question Macro for Automatic Font Size Change for Two Different Cell Values

    Hello,

    I will try to explain this as best as possible without attaching pictures (forum says "not a picture" at the top - even so, each time I screen shot, it comes out extremely blurry so it's essentially useless regardless). I have a group of cells merged together (G11 through I17) that uses a formula to either return a 0 through 11 (numerical) result or a "SOP Error" result. When the numerical value shows, the font is 24 which is exactly what I need. When the SOP Error value shows, it remains 24 and I need it to change to 12 to fit properly. The numerical value comes back based on a series of check boxes being checked. The SOP error comes back and essentially overrides the numerical value when a specific check box, separate from the others related to the numerical value, is checked.

    I need a macro that will automatically changed the font size to 12 when the SOP Error value is returned but remains at 12 for any other value. I've tried googling and copying and pasting various macro codes I've found online but nothing seems to work. I'm not sure if I'm just doing something wrong when it comes to pasting the code and expecting it to begin working by itself, or if there's something wrong with the codes I'm finding online. Any help would be greatly appreciated!

    A few codes I've tried online;
    Private Sub Worksheet_Calculate()
    Dim rng As Range
    Dim rCell As Range

    Set rng = Range("A1:A10")

    For Each rCell In rng
    If Len(rCell.Text) > 2 Or _
    Val(rCell.Value) > 10 Then
    rCell.Font.Name = "Arial"
    rCell.Font.Size = 16
    Else
    rCell.Font.Name = "Times New Roman"
    rCell.Font.Size = 12
    End If
    Next
    End Sub

    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim rCell As Range

    If Union(Target, Range("A1:A10")).Address = _
    Range("A1:A10").Address Then
    Application.EnableEvents = False
    For Each rCell In Target
    If Len(rCell.Text) > 2 Or _
    Val(rCell.Value) > 10 Then
    rCell.Font.Name = "Arial"
    rCell.Font.Size = 16
    Else
    rCell.Font.Name = "Times New Roman"
    rCell.Font.Size = 12
    End If
    Next
    Application.EnableEvents = True
    End If
    End Sub

    FYI, I'm not the most familiar with macros and the lingo as well. With that said, I may need any responses broken down into something I can easily understand lol.

    Also, if there's any more information I'm supposed to put in this thread, please let me know.

  2. #2
    Registered User
    Join Date
    01-02-2020
    Location
    Owings Mills, MD
    MS-Off Ver
    1911
    Posts
    4

    Re: Macro for Automatic Font Size Change for Two Different Cell Values

    Also, I'm using Office 2019

+ 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] Can I change Font size without changing cell size? Or confine row height change to one col
    By j_Southern in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-10-2018, 11:18 AM
  2. Replies: 7
    Last Post: 06-17-2018, 06:42 AM
  3. Macro to Change Font Size Based on if Cell Contains Specific Text
    By karpfy19 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-24-2016, 08:12 PM
  4. Change font size keeping the cell size fixed
    By mayurpatil in forum Excel General
    Replies: 1
    Last Post: 07-09-2015, 01:52 PM
  5. [SOLVED] How do I change a macro's font size?
    By dave60610 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-06-2006, 12:35 PM
  6. 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
  7. Replies: 2
    Last Post: 11-17-2005, 04:15 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