Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 150
Default linking worksheets

I want to create a way to link one worksheet in one workbook to a particular
sheet in another workbook. So when I click on the particular cell in the
main workbook I want it to open the particular sheet in the other workbook.
Is this possible?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 184
Default linking worksheets

Julie, without more detail, it is hard to know exactly what you are
looking for, but the answer is yes.

In the worksheet module you can place an event procedure that reacts
to a given behavior such as double clicking or clicking into another
cell. The code below fires when you double click in a cell within the
worksheet. ‘Target’ is the range or cell that associated with the
double click event in this example. When a cell is double clicked the
address is stored in the variable ‘stg’ and the cell’s value is stored
in a string variable ‘val’. Let us assume that the sheet that you
want to be active when the excel file is opened is actually the value
that is stored inside the cell. The cells A1 to A4 are associated with
separate files in this example. If you double clicked “A2” it would
open ‘file2.xls’ and try to activate a sheet that had the name of
whatever value was in that cell.

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel
As Boolean)
Dim stg, val As String
stg = Target.Address(0, 0)
val = Target.Value

Select Case stg
Case "A1"
Workbooks.Open Filename:= _
"D:\Documents\file1.xls"
ActiveWorkbook.Sheets(val).Activate
Case "A2"
Workbooks.Open Filename:= _
"D:\Documents\file2.xls"
ActiveWorkbook.Sheets(val).Activate
Case "A3"
Workbooks.Open Filename:= _
"D:\Documents\file3.xls"
ActiveWorkbook.Sheets(val).Activate
Case "A4"
Workbooks.Open Filename:= _
"D:\Documents\file4.xls"
ActiveWorkbook.Sheets(val).Activate
End Select
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
End Sub

HTH--Lonnie M.
Reply
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
Linking worksheets Iannelli Excel Worksheet Functions 1 February 18th 10 07:10 PM
Linking my worksheets Debbiek Excel Worksheet Functions 3 May 28th 08 11:26 PM
linking worksheets RobC Excel Discussion (Misc queries) 1 August 22nd 06 07:44 PM
Linking worksheets ghost635 New Users to Excel 1 May 19th 05 08:37 PM
Need Help linking worksheets Carolly New Users to Excel 5 January 27th 05 05:21 PM


All times are GMT +1. The time now is 02:22 PM.

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"