Pause a macro?

G

Guest

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
 
B

Bob Phillips

Have you looked at GetOpenFilename in VBA Help?

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
L

Lonnie M.

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.
 
L

Lonnie M.

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!
 
G

Guest

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
 

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