How do I use vb to move from worksheet to worksheet in a workbook.

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

Guest

I am using VB (Excel) and want to be able to move from sheet to sheet in a
macro and finish at the last sheet. Any ideas??
 
If you don't need to actually select the sheets, use something
like

Dim WS As Worksheet
For Each WS In ThisWorkbook.Worksheets
' do something with WS
Next WS

If you do need to select the sheets, put a Select statement
within the loop above:
WS.Select


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
With ActiveWorkbook
for each sh in .Worksheets
msgbox "in sheet: " & sh.Name & vbNewLine & _
"cell A1: " & sh.Range("A1").Value
Next
.Worksheets(.Worksheets.count).Select
End With
 

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

Back
Top