MsgBox compile error in Excell

J

Jerry Dyben

From Microsoft training on Loops. copied the following Do While Loop:

Sheets("Sheet1 (2)").Select
x = ActiveCell.Row
y = ActiveCell.Column
z = 0

Do While Cells(x, y).Value <> ""
x = x + 1
z = z + 1
Loop
MsgBox "There are "&z&" cells in the current range."

End Sub

Microsoft Visual Basic MsgBox in red and stated, "Expected:end of statement"
Someone wrote Close. Where and how to you type it into the MsgBox? New
beginner please be more specific.
 
C

Chip Pearson

Jerry,

You need spaces before and after the & characters. Without them,
VBA is attempting to use them as data type specifiers.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


message
news:[email protected]...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top