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

G

Guest

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
 
G

Guest

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
 
S

squenson via OfficeKB.com

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top