Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Linking worksheets | Excel Worksheet Functions | |||
Linking my worksheets | Excel Worksheet Functions | |||
linking worksheets | Excel Discussion (Misc queries) | |||
Linking worksheets | New Users to Excel | |||
Need Help linking worksheets | New Users to Excel |