ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do I use vb to move from worksheet to worksheet in a workbook. (https://www.excelbanter.com/excel-programming/324945-how-do-i-use-vbulletin-move-worksheet-worksheet-workbook.html)

Ed123

How do I use vb to move from worksheet to worksheet in a workbook.
 
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??

job

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


For Each wksht In ActiveWorkbook.Worksheets...

HTH,

Job

"Ed123" wrote in message
...
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??




Chip Pearson

How do I use vb to move from worksheet to worksheet in a workbook.
 
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





"Ed123" wrote in message
...
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??




Tom Ogilvy

How do I use vb to move from worksheet to worksheet in a workbook.
 
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

--
Regards,
Tom Ogilvy

"Ed123" wrote in message
...
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??





All times are GMT +1. The time now is 02:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com