Learn Excel - Simplify Life with Excel Concepts

Excel FileLen Function (VBA)

FileLen Function VBA Code

How to use the FileLen Function (VBA)

This Excel tutorial explains how to use the Excel FileLen function with syntax and examples using VBA.

SUMMARY:

The Excel VBA FileLen function returns the size of a file in bytes.
The file size can be returned in kilobytes, megabytes and other similar size units.

PURPOSE:

To get the size of a file in bytes.

RETURN VALUE:

The FileLen function returns a numeric value in bytes.

SYNTAX:

FileLen(pathname)

ARGUMENTS:

The FileLen function syntax has the following arguments:

  • pathname: Required. The pathname argument is a string expression that specifies a file name.
    • The pathname may include the directory or folder, and the drive.

REMARKS:

  • If the specified file is not available then an error will occur.
  • To obtain the length of an open file, use the LOF function.

Useful Links: Link 1Link 2Link 3Link 4