a sample question about excel VBA

¬

¬f©÷

How can I make msgbox like this?
¡÷ there are X sheets of this workbook
the first page name is : Sheets(1).Name
the secod page name is : Sheets(2).Name
¡õ until to the last page
the X page mane is : Sheets(X).Name


How can I write this module?
 
G

Gary Brown

Sub WorksheetNames()
Dim i As Long
Dim strAnswer As String

strAnswer = _
"There are " & Worksheets.Count & _
" sheets of this workbook"

For i = 1 To Worksheets.Count
strAnswer = strAnswer & vbCr & _
"Sheet " & i & " : " & _
Application.Worksheets(i).Name
Next i

MsgBox strAnswer

End Sub

Hope this helps
 

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