FreeFile function

Category: File / I-O & Environment

Summary

Next available file number.

Syntax

FreeFile [ (rangenumber) ] The optional rangenumber argument is a Variant that specifies the range from which the next free file number is to be returned. Specify a 0 (default) to return a file number in the range 1–255, inclusive. Specify a 1 to return a file number in the range 256–511.

Example

Remarks
Use FreeFile to supply a file number that is not already in use.

Microsoft Support Page

https://learn.microsoft.com/en-us/office/vba/language/reference/user-interface-help/freefile-function

Back to Functions