Results 1 to 3 of 3
  1. #1
    Lounger
    Join Date
    Apr 2008
    Posts
    41
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Row Height based on cells (Excel 2003)

    I really hope someone can help me. I am trying to do the following:

    Count the number of characters in each cell in the first column
    If the characters <40 Then make the cell/row height =15
    Else Wrap the text in the cell and autofit.

    In addition, I will make a static column length later. I want to be able to see all the text in each cell with height based on criteria.

    I have my best attempt attached.
    Attached Files Attached Files

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Row Height based on cells (Excel 2003)

    Welcome to Woody's Lounge!

    You were almost there, only the parentheses in the line that counts the characters were not placed correctly. Try this version:
    <code>
    Sub SizeRows()
    Dim i As Integer
    Dim lRow As Long

    lRow = Cells(Rows.Count, 1).End(xlUp).Row

    For i = 1 To lRow
    If Len(Cells(i, 1)) < 40 Then
    Cells(i, 1).RowHeight = 15
    Else
    Cells(i, 1).WrapText = True
    Cells(i, 1).EntireRow.AutoFit
    End If
    Next i
    End Sub</code>

  3. #3
    Lounger
    Join Date
    Apr 2008
    Posts
    41
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Row Height based on cells (Excel 2003)

    Thank you! I reviewed it a hundred times and just could not see it! Sorry for the lack of detail.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •