Return to VBA Code Examples

VBA Print Statement

Print Description

Writes display-formatted data to a sequential file.

Print Syntax

The Print 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 Print 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(“A1:D5”) in a sheet like the above picture to a file, you can use the following code.

The output to the file “Print_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!