VBA - Opening a file within a macro

tanyaleblanc

Board Regular
Joined
Mar 16, 2019
Messages
145
Hi, when I open a file within a macro, I'm typically hitting F8 so that I can see if all the step are working properly, but when I open a file within the macro, it runs the macro fully, is there anyway to prevent this so that I can just keep hitting F8 to see if I have an errors and the information is working correctly.

[ub Filter()Dim lRow As Long
Dim fd As Office.FileDialog


lRow = ActiveSheet.Range("A500").End(xlUp).Row
If AutoFilterMode = True And FilterMode = True Then ActiveSheet.ShowAllData
lRow = ActiveSheet.Range("A500").End(xlUp).Row

Range("B9").Select
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC[2],'[Finance Extract1.xls]Sheet1'!R8C4:R500C4,1,FALSE)"
Selection.AutoFill Destination:=Range("B9:B500")
Range("B9:B500").Select

Set fd = Application.FileDialog(msoFileDialogFilePicker)


'open finance rec
With fd
.AllowMultiSelect = False
.Title = "Please select the file."

.Filters.Clear

If .Show = True Then
txtfilename = .SelectedItems(1)
Workbooks.Open txtfilename
End If]
 
Don't use a message box, simply put the word Stop wherever you want the code to stop,you than then use F8
 
Upvote 0

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,213,484
Messages
6,113,920
Members
448,533
Latest member
thietbibeboiwasaco

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top