Row height randonly(?) changing to zero

MOB

Well-known Member
Joined
Oct 18, 2005
Messages
1,066
Office Version
  1. 365
Platform
  1. Windows
I've recently made some improvements to a reporting spreadsheet at the company I'm currently working at, nothing spectacular, just automating tasks etc.

I am now seeing the occasional row height changing to zero, too many times to be a coincidence, and I'm fairly sure not user created.

None of my code affects row height as far as I'm aware.

Any pointers as what could be causing this?

Also, is there a way to use a formula to report the presence of a zero height row somehow? I have looked at this great option https://www.mrexcel.com/forum/excel-questions/501867-there-formula-displays-row-height.html by Fazza, but I could do with a quick formula that looks at a range and tells me, rather than multiple formulae?

I think I know the answer to the last point but here's hoping!

TIA
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
How about a User Defined Function?

After adding the code....use this formula in one cell in your sheet
=ZeroHeight()

Used range tested and formula returns either "none" or list of row numbers

Paste to a Standard module
Code:
Function ZeroHeight() As String
    Application.Volatile
    Dim r As Range, msg As String:  msg = "none"
    For Each r In Application.Caller.Parent.UsedRange.Rows
        If r.RowHeight = 0 Then
            If msg = "none" Then msg = r.Row Else msg = msg & ", " & r.Row
        End If
    Next r
        ZeroHeight = msg
End Function
 
Upvote 0
I like that thanks!

What about if I only wanted to check rows 6 to "lastrow"?
 
Upvote 0
Keeps things simple...
Code:
For Each r In Application.Caller.Parent.UsedRange.Offset(5).Rows

If you wanted more flexibilty then the funtion could be amended to take a string of row numbers that could be ignored
 
Last edited:
Upvote 0
Thanks - tried the amendment, in my example data the rows are from 6 to 66 - 66 being "lastrow" - the code is returning many rows after 66 that I need to ignore
 
Upvote 0
formula now in this style - numbers are first row and last row
=ZeroHeight(5,50)

Code:
Function ZeroHeight(firstRow As Long, lastRow As Long) As String
    Application.Volatile
    Dim r As Range, msg As String:  msg = "none"

    For Each r In Application.Caller.Rows(firstRow).Resize(lastRow - firstRow + 1, 1)
        Debug.Print r.Address, r.RowHeight
        If r.RowHeight = 0 Then
            If msg = "none" Then msg = r.Row Else msg = msg & ", " & r.Row
        End If
    Next r
        ZeroHeight = msg
End Function

If you prefer to calculate last row, then I need a starting point
- perhaps enter a cell A5 as the first cell (gives row 5) and for VBA to determine last cell with formula\value in that column?
- some other determinant?
 
Last edited:
Upvote 0
Great thanks :-)

Ended up with this;

=ZeroHeight(6,LOOKUP(2,1/(A:A<>""),ROW(A:A))-1)

Which determines the last populated row.

Many thanks for your help!
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top