Return to VBA Code Examples

VBA Write Statement

Write Description

Writes data to a sequential file.

Write Syntax

The Write statement contains 2 arguments:

FileNumber: Any valid file number.

OutputList: Optional. One or more comma-delimited numeric expressions or string expressions to write to a file.

Examples of Excel VBA Write Function

First Name Last Name Age Gender
Robert Stepp 20 Male
Jennifer Mariscal 33 Female
David Romig 35 Male
Carmel Ingram 26 Female

To output Range(“A2:D5”) in a sheet like the above picture to a file, you can use the following code.

The output to the file “Write_Output.txt”:


VBA Coding Made Easy

Stop searching for VBA code online. Learn more about AutoMacro - A VBA Code Builder that allows beginners to code procedures from scratch with minimal coding knowledge and with many time-saving features for all users! vba save as

Learn More!