VBA Close Statement

Close Description

Concludes input/output (I/O) to a file opened by using the Open statement.

Close Syntax

Close [FileNumberList]

FileNumberList: [Optional] one or more file numbers that use the following syntax, where filenumber is any valid file number: [[ # ] filenumber ] [ , [ # ] filenumber ] . . .

Examples of Excel VBA Close Statement

Open "D:\test.txt" For Input As #1
    ' Read the file
Close
Open "D:\test.txt" For output As #1
    ' Write to the file
Close #1
Open "D:\test1.txt For Input As #1
Open "D:\test2.txt For Input As #2
    ' Read 2 files
Close #1, #2