formula to lookup file size and # of sheets in workbk

CA_User

Board Regular
Joined
Nov 5, 2004
Messages
126
Hello

is there a formula i can use that tells me how large my file is and how many sheets I have in the file? Thanks
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Good evening CA_User

Two really quick'n'dirty functions which will do the job, there isn't a native Excel function.

Code:
Function CountShts()
CountShts = Worksheets.Count
End Function

Function FileSize()
FileSize = (FileLen(ActiveWorkbook.FullName) / 1024)
End Function

Copy the code above into a module in the VBE, and you will have two new functions to use :

=CountShts()
Will return the number of sheets in the workbook.

=FileSize()
Will return the size of the workbook in Kb. This function will return an error if the file is not saved.

HTH

DominicB
 
Upvote 0
Hello CA_User,
is there a formula i can use that tells me how large my file is and how many sheets I have in the file?
As far as I know there is no native function for this but here's something you can try.
Put these UDFs into a standard module.
Code:
Public Function SheetCount() As String
Application.Volatile
SheetCount = "There are " & ThisWorkbook.Sheets.Count & " sheets in this workbook."
End Function

Public Function FileSize() As String
Application.Volatile
FileSize = "The file size of this workbook is " & FileLen(ActiveWorkbook.FullName) / 1024 & " KBytes."
End Function

Then - after making sure you have saved the workbook - (ie, given it a name),
you can use these functions like so:
In one cell: =SheetCount()
And in another: =FileSize()
 
Upvote 0
this works great! Is there a way to store this in my personal workbook or excel startup template where I can have it all the time instead of having to save it to each workbook? Thanks!
 
Upvote 0
You can find the no of sheets without VBA.

Goto Insert>Name...Define..., enter a name say NoSheets.

Then enter this in the refers to box and hit Add

=GET.WORKBOOK(4)

You can now enter =NoSheets in the worksheet to get the no of worksheets.

I'm still trying to see if there's a similar approach for file size, but I fear not.:)
 
Upvote 0

Forum statistics

Threads
1,214,636
Messages
6,120,669
Members
448,977
Latest member
moonlight6

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