Sub GetSheetNames_andRowCounts()
Dim i As Integer
Dim j As Integer
Dim SheetCnt As Integer
Dim lstRow As Long
Dim ws1 As Worksheet
Dim SheetName As String
With Application
.DisplayAlerts = False
.EnableEvents = False
.ScreenUpdating = False
End With
On Error Resume Next
'Delete the Target Sheet on the document (in case it exists)
Sheets("Target").Delete
SheetCnt = Worksheets.Count
'Add the Target Sheet
Sheets.Add after:=Worksheets(SheetCnt)
ActiveSheet.Name = "Target"
Set ws1 = Worksheets("Target")
j = 1
'Combine the sheets
For i = 1 To SheetCnt
Worksheets(i).Select
'check what is the last row with data using column A as a reference
lstRow = ActiveSheet.Cells(65536, "A").End(xlUp).Row
'get the name of the sheet
SheetName = Worksheets(i).Name
'assign the values to the Target sheet
ws1.Cells(j, 1).Value = SheetName
ws1.Cells(j, 2).Value = lstRow1
j = j + 1
Next
With Application
.DisplayAlerts = True
.EnableEvents = True
.ScreenUpdating = True
End With
Sheets("Target").Select
Cells.EntireColumn.AutoFit
Range("A1").Select
End Sub
4 comentários:
lstRow = ActiveSheet.Cells(65536, "A").End(xlUp).Row
Just curious what this line should read in Excel 2010. The 65536 is for Excel 2003 files, correct?
Great site - love the helpful tips! Thank you (obrigado!)
lstrow = ActiveSheet.Cells(ActiveSheet.Rows.Count, "A").End(xlUp).Row
I had changed the 1stRow to 1stRow = ActiveSheet.Cells(ActiveSheet.Rows.Count,"A").End(x1Up).Row ; however this didn't count the number of rows for me.
It give me the sheet names in the Target tab, but that is all. How can I fix this?
dich vu ke toan dich vu lam bao cao tai chinh tín
khóa học kế toán thực hành re
công ty dịch vụ kế toán
dich vu ke toan thue tai bac ninh
dịch vụ kế toán trọn gói tại hà nội
dịch vụ kế toán tại tp.hcm
dịch vụ báo cáo thuế
dịch vụ quyết toán thuế uy
trung tâm đào tạo kế toán tại tphcm
trung tâm đào tạo kế toán tại cầu giấy tín
trung tâm đào tạo kế toán tại long biên
trung tâm đào tạo kế toán tại hà đông re
trung tâm kế toán tại thanh xuân
trung tâm kế toán tại bắc ninh
trung tâm kế toán tại bình dương
trung tâm kế toán tại hải phòng
dịch vụ quyết toán thuế tại quận bình thạnh
dịch vụ quyết toán thuế tại quận tân phú
dịch vụ quyết toán thuế tại quận 5
dịch vụ quyết toán thuế tại quận 3
dịch vụ quyết toán thuế tại tphcm
dịch vụ quyết toán thuế tại quận cầu giấy
dịch vụ quyết toán thuế tại quận long biên
dịch vụ quyết toán thuế tại quận hà đông
dịch vụ quyết toán thuế tại quận thanh xuân
Post a Comment