View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default Selecting Next Worksheet

Private Sub Workbook_Open()
Dim sh as Worksheet
for each sh in Thisworkbook.Worksheets
if sh.Visible = xlSheetVisible then
If sh.Range("B25").Value = "" Then
sh.Select
sh.Range("B25").Select
exit for
End If
end if
Next
End Sub

--
Regards,
Tom Ogilvy


"Fleone" wrote:

Thanks so much Tom, it works perfectly.
Just as an FYI, if any of the sheets in the workbook are hidden and have
empty cells in the range value the VB will post an error. It wasn't a big
deal for me as I just use the hidden sheets as range separators.
Thanks again!

"Tom Ogilvy" wrote:

Private Sub Workbook_Open()
Dim sh as Worksheet
for each sh in Thisworkbook.Worksheets
If sh.Range("B25").Value = "" Then
sh.Select
sh.Range("B25").Select
exit for
End If
Next
End Sub

--
Regards,
Tom Ogilvy


"Fleone" wrote:

I would like to open a workbook and search the worksheets until the first
blank cell B25 is located and have the worksheet containing the blank cell
B25 be the active worksheet.
This is what I came up with and it is not working because I have a Next with
no For.

Private Sub Workbook_Open()
If B25 = "" Then
Next Worksheet.Select
End If

End Sub
Thanks for any help!