Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Selecting a row in a worksheet | Excel Worksheet Functions | |||
selecting a worksheet | Excel Worksheet Functions | |||
selecting cell range in other worksheet without switching to worksheet | Excel Programming | |||
Selecting Last Worksheet | Excel Programming | |||
Selecting a worksheet with a ComboBox | Excel Programming |