Forum Discussion
Excel VBA "For loop" does not respond
I had a problem debugging a VBA program. I could not step into a "For loop". I wrote a simple loop to see if the problem was persistent. This file is attached. When I open Module1 and attempt to step into the macro, I get the error message below.
I don't care about the macro. I care the macro will not run and that I can't step into it to debug it. I am sure you will be able to do so. My VBA is corrupted or something and I don't know how to fix it.
I know VBA is not the most stable platform. When I had problems like this, I would reload Excel and the problems would go away. This time, I reloaded Office. But the problem persists.
John DeBaise
1 Reply
A macro is a piece of code that begins with Sub macroname() and ends with End Sub.
Both are missing from your code.
It should look like this:
Sub Test() Dim i As Integer For i = 0 To 10 Range("A1").Select Selection.End(xlDown).Select Selection.Offset(1, 0).Select Paste Next i End SubYou will then be able to step into the code etc.