PC Review


Reply
Thread Tools Rate Thread

auto run macro on open of workbook if cell a1=A

 
 
=?Utf-8?B?cHN3YW5pZQ==?=
Guest
Posts: n/a
 
      11th Aug 2007
hi..

i need a macro to run when a user open the workbook.

should be something like.

if sheet1 range a1="a"
Application.Run "INVENTRY.xls!newday.newday"

if sheet1 range a1="b"
Application.Run "INVENTRY.xls!update.update"

if sheet1 range a1="c"
select sheet1 rangec115


i allready got the 2 macros (update & newday) working but need the workbook
to check the condition of range a1 in order to perform the various tasks

 
Reply With Quote
 
 
 
 
=?Utf-8?B?TWlrZSBI?=
Guest
Posts: n/a
 
      11th Aug 2007
Hi,

Try this

Private Sub Workbook_Open()
Select Case Sheets("sheet1").Range("A1").Value
Case "a"
Application.Run "INVENTRY.xls!newday.newday"
Case "b"
Application.Run "INVENTRY.xls!update.update"
Case "c"
Sheets("Sheet1").Range("C15").Select
End Select
End Sub

Mike

"pswanie" wrote:

> hi..
>
> i need a macro to run when a user open the workbook.
>
> should be something like.
>
> if sheet1 range a1="a"
> Application.Run "INVENTRY.xls!newday.newday"
>
> if sheet1 range a1="b"
> Application.Run "INVENTRY.xls!update.update"
>
> if sheet1 range a1="c"
> select sheet1 rangec115
>
>
> i allready got the 2 macros (update & newday) working but need the workbook
> to check the condition of range a1 in order to perform the various tasks
>

 
Reply With Quote
 
=?Utf-8?B?cHN3YW5pZQ==?=
Guest
Posts: n/a
 
      11th Aug 2007
and this i paste in the

right click on thingie next to file and then view?

 
Reply With Quote
 
squenson via OfficeKB.com
Guest
Posts: n/a
 
      11th Aug 2007
Sub RunWhenOpenDocument()

Select Case Range("Sheet1!A1").Value
Case "a"
Application.Run "INVENTRY.xls!newday.newday"
Case "b"
Application.Run "INVENTRY.xls!update.update"
Case Else
Range("Sheet1!C115").Select
End Select

End Sub

Save this macro in Sheet1, and in ThisWorkbook, under the event Open, insert
the line
Sheet1.RunWhenOpenDocument

Stephane Quenson

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200708/1

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to code VBA: Auto open workbook and run macro =?Utf-8?B?TWFyY2g=?= Microsoft Excel Misc 4 8th Nov 2007 08:25 PM
auto-open macro lost within workbook windsurferLA Microsoft Excel Programming 2 16th Dec 2006 11:09 PM
auto run macro on workbook open Mcasteel Microsoft Excel Programming 0 15th Nov 2004 03:04 PM
auto run macro on workbook open Mcasteel Microsoft Excel Programming 2 15th Nov 2004 02:59 PM
auto run macro at workbook open Juan Guemes Microsoft Excel Programming 2 28th Aug 2004 10:55 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:16 PM.