Why does "Step Into" stop after I open my input file?

SandsB

Well-known Member
Joined
Feb 13, 2007
Messages
705
Office Version
  1. 365
Platform
  1. Windows
I need to debug a part of a macro - the error is long after the code below. When I do a Step Into, as soon as I point to the input file I want the whole macro runs to completion. Why is that and how can I prevent it so I can verify my code line by line?

Sub GetStuff()
Dim FileToOpen As Variant
Dim OpenBook As Workbook
Application.ScreenUpdating = False
FileToOpen = Application.GetOpenFilename(Title:="Browse for your File & Import Range", FileFilter:="Excel Files (*.csv*),*csv*")
If FileToOpen <> False Then
Set OpenBook = Application.Workbooks.Open(FileToOpen)
Application.DisplayAlerts = True
OpenBook.Sheets(1).Range("A1:W9999").Copy
ThisWorkbook.Worksheets("Yourstuff").Range("A1").PasteSpecial xlPasteValues
OpenBook.Close False
Application.DisplayAlerts = True
End If

Sheets("Yourstuff").Select
Last = Cells(Rows.Count, "L").End(xlUp).Row
For i = Last To 1 Step -1
If (Cells(i, "L").Value) <> Worksheets("Sheet3").Range("D13") Then
Cells(i, "A").EntireRow.Delete
End If
Next i
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
When you step into the code that opens another workbook, that opened workbook becomes the active workbook. I have learned to just accept it, select the VBE and continue stepping.
 
Upvote 0
RoryA - from that link I got something so obvious I'm ashamed of myself. After the file is opened, I added End Sub followed by a line that said Sub Part2(). I just run the first part, then step into the second.
Thanks
 
Upvote 0

Forum statistics

Threads
1,215,076
Messages
6,122,988
Members
449,093
Latest member
Mr Hughes

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