+ Reply to Thread
Results 1 to 9 of 9

Row height based on cell value

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    10-09-2012
    Location
    Adelaide, South Australia
    MS-Off Ver
    Excel 2010
    Posts
    135

    Row height based on cell value

    Hello,
    I am trying to find a macro to adjust the row height depending on the value in column B
    More specifically if column B contains the value "#Break" I need to adjust the row height to = 9.75 (13 Pixels)

    It is a fairly basic one but I have not been able to find any answers by searching through the forum

    Can anyone help?

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: Row height based on cell value

    Hi

    How's this

    Sub aaa()
      For i = 2 To Cells(Rows.Count, 2).End(xlUp).Row
        If InStr(1, Cells(i, 2), "#Break") > 0 Then
          Cells(i, 1).EntireRow.RowHeight = 9.75
        End If
      Next i
    End Sub
    rylo

  3. #3
    Forum Contributor
    Join Date
    10-09-2012
    Location
    Adelaide, South Australia
    MS-Off Ver
    Excel 2010
    Posts
    135

    Re: Row height based on cell value

    Like a dream! Thankyou Rylo. :D
    If I wanted to delete those rows, would that be similar?

  4. #4
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: Row height based on cell value

    Hi

    Sure, but you have to run the loop backwards (
    for i = cells(rows.count,1).end(xlup).row to 2 step -1
    ) and then
    cell(i,1).entirerow.delete
    rylo

  5. #5
    Forum Contributor
    Join Date
    10-09-2012
    Location
    Adelaide, South Australia
    MS-Off Ver
    Excel 2010
    Posts
    135

    Re: Row height based on cell value

    Like this?
    Sub Delete_Breaks()
      For i = Cells(Rows.Count, 1).End(xlUp).Row To 2 Step -1
        If InStr(1, Cells(i, 2), "#Break") > 0 Then
          cell(i, 1).EntireRow.Delete
        End If
      Next i
    End Sub

  6. #6
    Forum Contributor
    Join Date
    10-09-2012
    Location
    Adelaide, South Australia
    MS-Off Ver
    Excel 2010
    Posts
    135

    Re: Row height based on cell value

    no joy, I have made an error somewhere along the line

  7. #7
    Forum Contributor
    Join Date
    10-09-2012
    Location
    Adelaide, South Australia
    MS-Off Ver
    Excel 2010
    Posts
    135

    Re: Row height based on cell value

    please forgive my lack of technical understanding, I am still learning

  8. #8
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: Row height based on cell value

    Hi

    Sorry, my bad. Delete line should be

    cells(i, 1).EntireRow.Delete
    rylo

  9. #9
    Forum Contributor
    Join Date
    10-09-2012
    Location
    Adelaide, South Australia
    MS-Off Ver
    Excel 2010
    Posts
    135

    Re: Row height based on cell value

    Rylo, you sir are a legend. Thankyou

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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