LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Cads
 
Posts: n/a
Default Activating a worksheet through use of a variable

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
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
Update Worksheet to Worksheet Wendy Gunter Excel Worksheet Functions 0 October 5th 05 02:36 PM
Using VBA to create a new worksheet, and then target new worksheet brianproctorla Excel Discussion (Misc queries) 1 September 27th 05 12:50 AM
Search/Match between 2 x separate Worksheets and populate result in third worksheet Alan Bartley Excel Discussion (Misc queries) 1 April 11th 05 05:21 AM
Weekly Transaction Processing Ralph Howarth Excel Worksheet Functions 4 January 19th 05 05:37 AM
copyright and worksheet protection dow Excel Discussion (Misc queries) 2 January 3rd 05 03:07 PM


All times are GMT +1. The time now is 01:22 AM.

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

About Us

"It's about Microsoft Excel"