Results 1 to 10 of 10

Thread: Summary Of Maximum Rows Used Across Each Sheet In A Workbook

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #6
    Forum Guru Rick Rothstein's Avatar
    Join Date
    Feb 2012
    Posts
    662
    Rep Power
    15
    Quote Originally Posted by Rick Rothstein View Post
    Unfortunately, it is back to the drawing boards for me...
    Okay, I am back from the drawing board and I think the following code will work correctly in all scenarios discussed previously...
    Code:
    Sub SheetUsageByWorksheet()
      Dim Col As Long, X As Long, MaxRow As Long, LastRow As Long, PrevRow As Long, LastCol As Long
      Dim Addr As String, TextOut As String, Dashed() As String, Spaced() As String, WS As Worksheet
      On Error GoTo NoData
      For Each WS In Worksheets
        Addr = ""
        MaxRow = 0
        LastCol = WS.Cells.Find("*", , xlFormulas, , xlByColumns, xlPrevious).Column
        If LastCol Then
          For Col = 1 To LastCol
            LastRow = WS.Cells(Rows.Count, Col).End(xlUp).Offset(1).Row - 1
            If LastRow > MaxRow Then MaxRow = LastRow
            If Len(Cells(Rows.Count, Col).Formula) > 0 Then LastRow = Rows.Count
            Addr = Trim(Addr & " " & Split(Cells(1, Col).Address, "$")(1) & "-" & LastRow)
          Next
          Dashed = Split(Addr, "-")
          For X = 1 To UBound(Dashed) - 1
            If Val(Dashed(X)) = Val(Dashed(X + 1)) Then Dashed(X) = ":" & Mid(Dashed(X), InStr(Dashed(X), " ") + 1)
          Next
          Addr = Replace(Join(Dashed, "-"), "-:", ":")
          Spaced = Split(Addr)
          For X = 0 To UBound(Spaced)
            If Spaced(X) Like "*:*" Then Spaced(X) = Left(Spaced(X), InStr(Spaced(X), ":")) & Mid(Spaced(X), InStrRev(Spaced(X), ":") + 1)
          Next
          Addr = "For '" & WS.Name & "' tab with up to " & MaxRow & " rows in " & LastCol & " columns." & vbLf & vbLf & Replace(Join(Spaced), " ", "   ") & vbLf & vbLf
        End If
        TextOut = TextOut & Addr
    Continue:
      Next
      MsgBox TextOut
      Exit Sub
    NoData:
      Resume Continue
    End Sub
    Last edited by Rick Rothstein; 09-04-2015 at 07:28 PM.

Similar Threads

  1. Replies: 1
    Last Post: 05-24-2015, 03:02 PM
  2. VBA to Get Sales SUMMARY of Multipple Sheet
    By mag in forum Excel Help
    Replies: 0
    Last Post: 12-27-2012, 07:39 PM
  3. VBA to Get SUMMARY of Multipple Sheet
    By mag in forum Excel Help
    Replies: 10
    Last Post: 12-27-2012, 04:09 PM
  4. Chart Summary help
    By sanjeevi888 in forum Excel Help
    Replies: 1
    Last Post: 07-08-2012, 06:06 PM
  5. Replies: 9
    Last Post: 09-09-2011, 02:30 AM

Posting Permissions

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