SandsB
Well-known Member
- Joined
- Feb 13, 2007
- Messages
- 730
- Office Version
- 365
- Platform
- 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
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