tomocafe
tomocafe

Reputation: 1544

Excel VBA Print function inserting new line / CR

I am trying to print to a file using the following statement

Print #1, "String1"; Tab(20); "String2"; Tab(15); "String3"

such that the file reads

String1                    String2               String3

and then begins a new line. But what actually results from execution of the above statement is:

String1                    String2
               String3

For reasons I can't seem to figure out, a new line is inserted after String2, but not after String1.

If anyone knows how to fix this, please do tell. Thank you!

Upvotes: 0

Views: 1852

Answers (1)

Tim Williams
Tim Williams

Reputation: 166366

Tab(20); doesn't insert 20 tabs - it sets the position to the "20th" tab (where ever that is). You can't then set it back to 15 on the same line...

Upvotes: 1

Related Questions