Code to open external workbook

Closed
G - Nov 24, 2010 at 11:03 AM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 - Nov 30, 2010 at 10:25 AM
Hello,
I have searched all over for this one and can't seem to find it... I am wanting to open a workbook if an age entry is below 12. I am trying to create a macro in my main workbook to open 'Master Kids 2010.xlsm'.
Any ideas please - I'm a complete noob at this. Using Office 2007 on XP SP3.
Thanks in advance...

Traveller_1

1 response

TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 552
Nov 30, 2010 at 10:25 AM
Hi G,

OK, so you have an open workbook where you input someone's age in cell A1.
Whenever the entered age drops below 12 you want to open a specific workbook. If this is correct use the following code, which you implement in the sheet where the age is entered (right click on sheets tab and select "view code"):

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("A1")) Is Nothing Then Exit Sub
If Range("A1") < 12 Then Workbooks.Open Filename:="EnterYourFilenamesFullPathLike: C:\Excel\Master Kids 2010.xlsm"
End Sub

Let me know how this works for you.

Best regards,
Trowa
0