Getting # of rows in worksheets

cuetipper

Board Regular
Joined
Nov 9, 2018
Messages
67
I have a workbook for clients, one worksheer per. Is it possible to loop thru those workbooks an create a list of how many items are in each worksheet tabulated by worksheet name? So if I have three workshets [a,b,c] I would get a fourth worksheet with two columns r1c1=a, r2c1=b, r3c1=c and column 2 would total the # of entries per so r2c2 =5, r2c2 =35, r2c3=15?
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Are you looking for a macro to do this?
You could just add the sheet and use the COUNTA function if you have a contiguous range on each sheet down a specific column.
 
Upvote 0
Is there a particular column on each sheet that will always be filled?
 
Upvote 0
Try the Following, I assume you don't have a Sheet named Summary. This will delete the Summary sheet if it exists, add a new one and then input the data you requested.

Just change the highlighted summarys to be the name of whatever you want the sheet to be called if you already have a summary sheet

Code:
Option Explicit

Sub Summary_Sheet_Counter()
'https://www.mrexcel.com/forum/excel-questions/1077636-getting-rows-worksheets.html


Dim LR As Variant
Dim WS As Worksheet
Dim WS_Count As Integer
Dim i As Integer, j As Integer


Application.ScreenUpdating = False


'Delete Summary Sheet
On Error Resume Next
    Worksheets("[COLOR=#ff0000]Summary[/COLOR]").Activate
On Error GoTo 0


If ActiveSheet.Name = "[COLOR=#ff0000]Summary[/COLOR]" Then
    Application.DisplayAlerts = False
        Worksheets("[COLOR=#ff0000]Summary[/COLOR]").Delete
    Application.DisplayAlerts = True
End If


WS_Count = ActiveWorkbook.Sheets.Count


'Create New Summary Sheet
Worksheets.Add Before:=Worksheets(1)
    ActiveSheet.Name = "[COLOR=#ff0000]Summary[/COLOR]"


'Count last row in column A across all sheets
For i = 2 To WS_Count + 1
  LR = ActiveWorkbook.Sheets(i).Cells(Rows.Count, "A").End(xlUp).Row
    With Sheets("[COLOR=#ff0000]Summary[/COLOR]")
      .Cells(i, 1).Value = Sheets(i).Name
      .Cells(i, 2).Value = LR
    End With
Next i


Application.ScreenUpdating = True


End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,373
Messages
6,124,544
Members
449,169
Latest member
mm424

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