+ Reply to Thread
Results 1 to 2 of 2

a macro to format a row height and font, dependant upon a cell content

Hybrid View

PeterF a macro to format a row... 06-18-2011, 02:46 PM
barryleajo Re: a macro to format a row... 06-19-2011, 02:56 AM
  1. #1
    Registered User
    Join Date
    07-05-2009
    Location
    Bolton, England
    MS-Off Ver
    Excel 2007
    Posts
    9

    a macro to format a row height and font, dependant upon a cell content

    Dear guru's, I'm not one of them, but trying to learn....

    I have a sheet with multiple rows, any row with a digit of >0 in a specific cell needs to have it's font size increased and row height to enable fit.

    It cannot be done through conditional formatting (I'm using Excel 2007), but reckon a macro to look at each row in turn might do the trick.

    Advice and guidance most welcome.

    Thanks in anticipation - Peter F.

  2. #2
    Valued Forum Contributor
    Join Date
    06-19-2010
    Location
    Holywell, N Wales, UK
    MS-Off Ver
    Excel 2013
    Posts
    470

    Re: a macro to format a row height and font, dependant upon a cell content

    Hi Peter
    Try this to get the idea - run it from a standard code module
    Sub incval()
    
    'Macro for PeterF
    'Assumes cells to be checked are in col A
    'With an option for the UsedRange
    'Assumes font size for this example = 20
    
    Dim rng As Range, cell As Range
    
    Set rng = Range("A1:A" & Range("A65356").End(xlUp).Row)
    'or
    'Set rng = ActiveSheet.UsedRange
    
        For Each cell In rng
            If cell > 0 Then
                cell.Font.Size = 20
                'Just in case row height has been adjusted manually
                cell.EntireRow.AutoFit
            End If
        Next
        
    End Sub
    Last edited by barryleajo; 06-19-2011 at 03:06 AM.

+ Reply to Thread

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