ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   excel (https://www.excelbanter.com/excel-discussion-misc-queries/148128-excel.html)

Mike

excel
 
I would like Excel to automaticaly open another worksheet if the value of a
particular cell has a particular value. Is this posible?

Toppers

excel
 
Try this: right click on tab, "view code" and copy/ paste


'-----------------------------------------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)
'-----------------------------------------------------------------
Const WS_RANGE As String = "A1:A1" '<<< change to your cell

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
If Target.Value = "ABC" Then '<<<< change value and file
Workbooks.Open Filename:="C:\Documents and
Settings\John\Desktop\test.xls"
End If
End If


ws_exit:
Application.EnableEvents = True
End Sub

"Mike" wrote:

I would like Excel to automaticaly open another worksheet if the value of a
particular cell has a particular value. Is this posible?


Mike H

excel
 
Yes it is, try this:-

Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
Set rng = Intersect(Target, Range("A1"))
If rng Is Nothing Then
Exit Sub
Else
If Target.Value 6 Then
Workbooks.Open ("C:\book2.xls")
Else
Exit Sub
End If
End If
End Sub

This is worksheet code so right click the sheet tab - view code and paste in.
If A1 value is greater than 6 then the workbook opens.

Mike
"Mike" wrote:

I would like Excel to automaticaly open another worksheet if the value of a
particular cell has a particular value. Is this posible?



All times are GMT +1. The time now is 11:38 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com