Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Hi
I'm trying to activate a worksheet based on its name which has been obtained from a Vlookup and passed to a variable(see below). However, whichever way I try to activate the sheet it doesn't seem to be able to understand what's in the variable. In the first case, it seems to think the variable is a number ('Subscript out of range') and it the second, it just ignores it. Any ideas on how I can do this ? Sub auto_open() Dim PTuName, PTinf As String Dim wks As Object PTuName = Get_User_Name PTinf = Application.WorksheetFunction _ .VLookup(PTuName, Worksheets("Names").Range("A2:B3"), 2) ' Activate the appropriate staff sheet Worksheets(PTinf).Activate ' Case 1 'For Each wks In Worksheets 'Case 2 ' If wks.Name = PTinf Then wks.Activate 'Next wks End Sub Ta -- Cads It''''s all meaningless in the end |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Update Worksheet to Worksheet | Excel Worksheet Functions | |||
Using VBA to create a new worksheet, and then target new worksheet | Excel Discussion (Misc queries) | |||
Search/Match between 2 x separate Worksheets and populate result in third worksheet | Excel Discussion (Misc queries) | |||
Weekly Transaction Processing | Excel Worksheet Functions | |||
copyright and worksheet protection | Excel Discussion (Misc queries) |