![]() |
Pause a macro?
Hi all...
I would like to record a macro that will pause while I browse to locate a spreadsheet. I need to perform the same functions on many spreadsheets that have different names, so I would like to start the macro, have it do a function or two, then pause while browse or type in a file name, then continue with the rest of the functions. Any ideas? Thanks! John |
Pause a macro?
Have you looked at GetOpenFilename in VBA Help?
-- HTH RP (remove nothere from the email address if mailing direct) "JohnnyJomp" wrote in message ... Hi all... I would like to record a macro that will pause while I browse to locate a spreadsheet. I need to perform the same functions on many spreadsheets that have different names, so I would like to start the macro, have it do a function or two, then pause while browse or type in a file name, then continue with the rest of the functions. Any ideas? Thanks! John |
Pause a macro?
Johnny, I use the following code to prompt me to browse for two files
and then it procedes with the rest of the codes. (This code is modified from a kind soul who posted to this user group). I think that you will be best served letting the code run and prompt you when it is appropriate for the file names. Dim FirstFile$, SecFile$ Dim fd As FileDialog Dim vrtSelectedItem As Variant FirstFile = "" SecFile = "" Set fd = Application.FileDialog(msoFileDialogFilePicker) On Error GoTo 0 With fd .InitialFileName = Sheets("Unique Items").Cells(16, 2) .InitialView = msoFileDialogViewDetails MsgBox "Select 'Previous Budget' file." If .Show = -1 Then For Each vrtSelectedItem In .SelectedItems FirstFile = vrtSelectedItem Next vrtSelectedItem End If MsgBox "Select 'Current Budget' file." If .Show = -1 Then For Each vrtSelectedItem In .SelectedItems SecFile = vrtSelectedItem Next vrtSelectedItem End If End With Err.Clear Set fd = Nothing HTH -- Lonnie M. |
Pause a macro?
Bob's suggestion is probably easier to use/learn. The reason I like
this method is that it lets me specify a default directory to start browsing -- using ".InitialFileName". Both get the job done. Good luck! |
Pause a macro?
Hi Bob:
I have never done anything with macros before. I will look into this to see if I can figure it out. Thanks for the tip! John "Bob Phillips" wrote: Have you looked at GetOpenFilename in VBA Help? -- HTH RP (remove nothere from the email address if mailing direct) "JohnnyJomp" wrote in message ... Hi all... I would like to record a macro that will pause while I browse to locate a spreadsheet. I need to perform the same functions on many spreadsheets that have different names, so I would like to start the macro, have it do a function or two, then pause while browse or type in a file name, then continue with the rest of the functions. Any ideas? Thanks! John |
All times are GMT +1. The time now is 08:59 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com