LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Use of Sheet CodeNames to Select Sheet in Different Workbook

I'm have a procedure built in one workbook that is designed to make
modifications to another workbook that is selected by the user. In my
procedure, I need to test the name of each worksheet in the user's
workbook to determine how to proceed on each sheet. For some reason, I
am unable to correctly point the appropriate sheet in the user's
workbook and capture its name in a variable. I have tried a few
different methods, none with any success.

Here is the abbreviated code:

Sub UnprotectSheets(strUpdateWb As String)
'where strUpdateWb is the name of an open workbook selected by the user

Windows(strUpdateWb).Activate
Dim wb As Workbook
Set wb = ActiveWorkbook

'Attempt #1
Dim ShName As String
ShName = wb.Sheet1.Name
MsgBox (ShName) 'yields a run-time error. code stops.

'Attempt #2
ShName = Sheet1.Name
MsgBox (ShName) 'gives me the sheet name from the immediate
workbook. I need the sheet name from the user-selected workbook

'Attempt #3
ShName = strUpdateWb.Sheet1.Name
MsgBox (ShName) 'run time error again

End Sub

Why can't I "see" the other workbook? Can anybody point me in the
right direction?

Thanks,
Randy Eastland

 
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
Loops with sheet codenames NEMB Excel Discussion (Misc queries) 0 February 13th 11 12:34 AM
How do I select price from sheet.b where sheet.a part no = sheet.b Sonny Excel Worksheet Functions 4 April 4th 06 05:08 PM
Select sheet tabs in workbook & save to separate workbook files stratocaster Excel Worksheet Functions 2 March 1st 06 03:35 PM
Use Sheet CodeNames to Select Sheet in Different Workbook Randy Excel Discussion (Misc queries) 1 June 10th 05 12:17 AM
Select a sheet to copy from one workbook to another holysoul[_4_] Excel Programming 2 June 4th 04 03:27 PM


All times are GMT +1. The time now is 11:24 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"