Microsoft Excel - How can I identify which rows in Excel are slowing down workbook calculation

Asked By Anderson Ahrenhold on 12-Aug-15 12:26 PM
I recently found the article on this site which includes VBA code to show which columns are slowest when an excel workbook is calculating.

Here is a link to the article: https://www.nullskull.com/a/1479/identifying-which-formulas-in-excel-are-slowing-down-workbook-recalaculation.aspx

I was hoping there was a way to change this VBA code so that it will do the same evaluation but by row instead of column.
Harry Boughen replied to Anderson Ahrenhold on 12-Aug-15 12:25 PM
I have not tested this but from a quick read through of the code, I think you can do what you want by a couple of changes in the function 'timesheet' near the beginning of the code listing.  As far as I can see you only need to change the reference from Columns to Rows in the For Each statement and the reference from Rows to Columns in the second Set statement.

If I get time later I will look at it further but in the meantime you could try it and let me know how it goes.
Harry Boughen replied to Anderson Ahrenhold on 12-Aug-15 12:25 PM
Just had to ignore everything else and try it and I missed a couple of subtle (or not so subtle) points

This is what the function should become

Function timeSheet(ws As Worksheet, routput As Range) As Range
    Dim ro As Range
    Dim c As Range, ct As Range, rt As Range, u As Range

    ws.Activate
    Set u = ws.UsedRange
    Set ct = u.Resize(, 1)
    Set ro = routput

    For Each c In ct.Rows
    Set ro = ro.Offset(1)
    Set rt = c.Resize(, u.Columns.Count)
    rt.Select
    ro.Cells(1, 1).Value = rt.Worksheet.Name & "!" & rt.Address
    ro.Cells(1, 2) = shortCalcTimer(rt, False)
    Next c
    Set timeSheet = ro

End Function
Anderson Ahrenhold replied to Harry Boughen on 12-Aug-15 08:44 AM
Thank you so much Harry! I had tried changing the function but I must have been off just a bit. Thanks again!
Anderson Ahrenhold replied to Harry Boughen on 12-Aug-15 12:26 PM
One more question.  How could I make the macro ignore calculating one of the sheets in my workbook?
Harry Boughen replied to Anderson Ahrenhold on 12-Aug-15 06:44 PM
Hello Anderson,

This should allow you to bypass a specific sheet.  Just change the name of the sheet to suit.  This segment is in the timeloopSheets Sub.

    If wsingle Is Nothing Then
    ' all sheets except one nominated
      For Each ws In Worksheets
      If ws.Name <> "Sheet3" Then
        Set ro = timeSheet(ws, ro)
      End If
      Next ws
    Else
    ' or just a single one
      Set ro = timeSheet(wsingle, ro)
    End If

Regards

Harry
Anderson Ahrenhold replied to Harry Boughen on 13-Aug-15 04:38 PM
Thank you again Harry! You have been a tremendous help with everything.