Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default Selecting Next Worksheet

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!
  #2   Report Post  
Posted to microsoft.public.excel.programming
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.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!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default Selecting Next Worksheet

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!

  #4   Report Post  
Posted to microsoft.public.excel.programming
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!

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Selecting a row in a worksheet Rochelle in Melbourne Excel Worksheet Functions 1 April 9th 09 11:34 AM
selecting a worksheet rocket0612 Excel Worksheet Functions 2 March 1st 06 09:47 AM
selecting cell range in other worksheet without switching to worksheet suzetter[_4_] Excel Programming 4 June 22nd 05 08:55 PM
Selecting Last Worksheet Alex Excel Programming 7 September 26th 04 09:35 PM
Selecting a worksheet with a ComboBox Todd Excel Programming 3 July 28th 04 09:37 PM


All times are GMT +1. The time now is 08:20 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"