+ Reply to Thread
Results 1 to 9 of 9

How to change font size automatically based on length of text but skipping every X rows

  1. #1
    Registered User
    Join Date
    04-08-2019
    Location
    Belfast, Northern Ireland
    MS-Off Ver
    Excel 2010
    Posts
    37

    How to change font size automatically based on length of text but skipping every X rows

    I have a macro that will change the font size of any cell that is longer than 12 characters but I need it to ignore every 8 rows. i.e. I need it to activate on row 10,19,28,37,etc but not 11,12,13,etc. I believe Mod Row would work but I can't figure out how to properly write it in. Any advice would be greatly appreciated.

    Here is what I have so far:


    Please Login or Register  to view this content.
    Thank you
    Last edited by mikeymeteora; 08-28-2019 at 10:28 AM.

  2. #2
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,743

    Re: How to change font size automatically based on length of text but skipping every X row

    Please wrap VBA code into CODE tag (or use # icon on menu).

    If you want to check each 8th row, maybe instead of:
    Please Login or Register  to view this content.
    do loop like below:
    Please Login or Register  to view this content.
    (btw, it looks like each 9th not 8th)
    Last edited by KOKOSEK; 08-28-2019 at 10:28 AM.
    Happy with my answer * Add Reputation.
    If You are happy with solution, please use Thread tools and mark thread as SOLVED.

  3. #3
    Registered User
    Join Date
    04-08-2019
    Location
    Belfast, Northern Ireland
    MS-Off Ver
    Excel 2010
    Posts
    37

    Re: How to change font size automatically based on length of text but skipping every X row

    Hi Kokosek thank you for the suggestion I'm very unsure how to implement that into my code. Could you post a complete version of what that would look like?

  4. #4
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,743

    Re: How to change font size automatically based on length of text but skipping every X row

    Try like this:

    Please Login or Register  to view this content.
    EDIT: misunderstanding, new code pasted.
    Last edited by KOKOSEK; 08-28-2019 at 11:46 AM.

  5. #5
    Registered User
    Join Date
    04-08-2019
    Location
    Belfast, Northern Ireland
    MS-Off Ver
    Excel 2010
    Posts
    37

    Re: How to change font size automatically based on length of text but skipping every X row

    Thank you but I can't get this to run, I have no idea what I doing wrong but it . I don't fully understand your code but it looks like it will only activate for Column A when I need it to work across the range A:AN.

  6. #6
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,743

    Re: How to change font size automatically based on length of text but skipping every X row

    Check post above yours after 'repost'.

  7. #7
    Registered User
    Join Date
    04-08-2019
    Location
    Belfast, Northern Ireland
    MS-Off Ver
    Excel 2010
    Posts
    37

    Re: How to change font size automatically based on length of text but skipping every X row

    Thank you. This does solve my issue, although Row 198 and Row 388 aren't being affected. -10 they are 21*9 and 42*9. But I can't figure out why that matters.

    Also I realise now that my cells are actually long formulas that draw in the text and the length function seems to be measuring the length of the formula instead of the displayed text. Is there a simple solution to make the macro read the displayed text instead of the formula?

  8. #8
    Registered User
    Join Date
    04-08-2019
    Location
    Belfast, Northern Ireland
    MS-Off Ver
    Excel 2010
    Posts
    37

    Re: How to change font size automatically based on length of text but skipping every X row

    I have figured out a solution by taking the mod line from your code and putting it into mine.

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

  9. #9
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,743

    Re: How to change font size automatically based on length of text but skipping every X row

    Try:

    Please Login or Register  to view this content.
    instead of:
    Please Login or Register  to view this content.

+ 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. Change Font size based on text value of other cell
    By food4feet in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-13-2018, 11:57 AM
  2. 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
  3. How to change the font size based on value of the cell?
    By redsab in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-27-2013, 08:59 PM
  4. [SOLVED] Change Font Size/Color on one line of an email automatically generated by a code.
    By coxb in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-18-2012, 01:55 PM
  5. [SOLVED] Automatically conditionally format font size based on text length
    By rh2705 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-09-2012, 10:47 PM
  6. 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
  7. [SOLVED] How do I "conditionally" change font size based on text length?
    By Found in Florida in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-10-2005, 07:05 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