a macro that launches another workbook automatically

  • Thread starter Thread starter mtjarrett
  • Start date Start date
M

mtjarrett

hey folks,

here's the deal. i need a macro that can sit on a sheet in a master
workbook and when i type a number (a filename) into a cell, lets say
cell D3, and then press enter, i need this macro to automatically open
the file i just typed. for instance, if i type in "406" into the cell
D3. when i press enter i want file 406.xls to open and minimize (so
that i can have access to information in that workbook).

thanks
 
Use the Change event for that sheet.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim bk as Workbook
If Target.Address = "$D$3" then
if not isempty(Target) then
set bk = workbooks.Open( Target.Value)
bk.Windows(1).WindowState = xlMinimized
End if
end if
End Sub

Right click on the sheet tab and select view code. Then put in a procedure
like the above. (you can paste this one in for a start.) You may need to
specify the path and so forth.
 

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

Back
Top