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

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,195
Members
453,021
Latest member
pingpong7117

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