MsgBox compile error in Excell

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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]...
 
Back
Top