Results 1 to 4 of 4

Automatically conditionally format font size based on text length

Threaded View

  1. #1
    Registered User
    Join Date
    09-09-2012
    Location
    Swindon UK
    MS-Off Ver
    Excel 2010
    Posts
    5

    Automatically conditionally format font size based on text length

    Greetings

    I have a staff rota spreadsheet which shows D for rostered days N for nightshift H for holiday and various other abbreviations and I want the cell to automatically change font size for the following conditions:
    text length <=2 I want font size to be 11
    text length = 3 I want the font size to be 10 and
    text length >3 I want the font size to be 5

    Being a VBA 'feartie' (I am trying here but its so difficult,dont get me wrong I just love wasting the time messing with VBA but I GIVE UP on this one :-( ) I wonder if anyone might be able to help. I've googled for some ready made code for this and found similar solutions that I have tried to adapt with zero success. What I have learned is:

    I need a 'ByVal Target is Range' statement
    I need to declare and dimension a variable as a range object which I have called 'cr'
    I think a case statement will do the trick.

    I've got as far as:

    Case (Len(cr.Text)) <= 2
        cr.Font.Size = 11
    
    Case (Len(cr.Text)) = 3
        cr.Font.Size = 10
    
    Case (Len(cr.Text)) > 3
        cr.Font.Size = 5
    
    Case Else
        cr.Font.Size = 11
    End Select
    Which doesn't create any vba error messages, HOWEVER, when I run the code ... Dan Dan Daaaaaannnnnn!!!!! .... NOTHING Happens

    All help, advice, suggestions very gratefully received.

    TIA

    Rob
    Last edited by JBeaucaire; 09-09-2012 at 06:39 PM. Reason: Added code tags, as per forum rules. Don't forget!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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