ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Putting Cursor in Cell A1 of each Worksheet, then ending cursor on smalest sheet name according to VBA Editor (https://www.excelbanter.com/excel-programming/389333-putting-cursor-cell-a1-each-worksheet-then-ending-cursor-smalest-sheet-name-according-vba-editor.html)

Matt[_40_]

Putting Cursor in Cell A1 of each Worksheet, then ending cursor on smalest sheet name according to VBA Editor
 
Dim WkSheet AsWorksheet
For Each WkSheet In ActiveWorkbook.Worksheets
WkSheet.Activate
ActiveSheet.Range("A1").Activate
ActiveCell.Show
Next


This works beautifully. Now, I would like it to go to Sheet 1
everytime, but none of my sheets are named Sheet 1. I am referring to
the name of the sheet when you go to Visual Basic Editor. In each
workbook, it will show you each Sheet with the actual name of the
sheet in parenthesis. Can anyone help me out? Also, what if sheet 1
is not there, how about bring the cursor to the smallest sheet
number. For examle, if Sheet 1, Sheet 2, and Sheet 4 are missing, the
cursor would end up on Sheet 3 in cell A1 after it ran the code of
macro above. Thanks in advance.

Matt


NickHK

Putting Cursor in Cell A1 of each Worksheet, then ending cursor on smalest sheet name according to VBA Editor
 
Matt,
Depends what you mean by "the smallest sheet number".
ActiveWorkbook.Worksheets(1)

NickHK

"Matt" wrote in message
ups.com...
Dim WkSheet AsWorksheet
For Each WkSheet In ActiveWorkbook.Worksheets
WkSheet.Activate
ActiveSheet.Range("A1").Activate
ActiveCell.Show
Next


This works beautifully. Now, I would like it to go to Sheet 1
everytime, but none of my sheets are named Sheet 1. I am referring to
the name of the sheet when you go to Visual Basic Editor. In each
workbook, it will show you each Sheet with the actual name of the
sheet in parenthesis. Can anyone help me out? Also, what if sheet 1
is not there, how about bring the cursor to the smallest sheet
number. For examle, if Sheet 1, Sheet 2, and Sheet 4 are missing, the
cursor would end up on Sheet 3 in cell A1 after it ran the code of
macro above. Thanks in advance.

Matt





All times are GMT +1. The time now is 03:09 PM.

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