Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Go to First Visible Tab in Excel

Status
Not open for further replies.

Skolastix

Programmer
Jul 31, 2001
22
I have found the "ActiveWindow.ScrollWorkbookTabs Position:=xlFirst" code, but it only scrolls and does not select the 1st visible worksheet.

What is the code to make the 1st visiblee worksheet active WITHOUT referencing the sheet(#), worksheet(#) or the sheet("worksheetname")? The reason is that the name and position of the worksheett can change. Likewise, the user might delete and use a new worksheet at anytime and I have to account for that. The only constant is that the worksheet will ALWAYS be visible.

Thanks for your help!!!
 

This is the VB6 forum - you need the VBA forum - forum707

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 

Assuming you have a Workbook object that you are using, something like this should work for you. (This is how it could be done with VBA):
Code:
Function FirstVisibleWorksheet(AWorkBook As Workbook) As String
Dim w As Worksheet
For Each w In Worksheets
  If w.Visible Then
    FirstVisibleWorksheet = w.Name
    Exit For
  End If
Next w
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top