Problem in VBA Debugger

Asked

Viewed 18 times

-1

Good morning!

When I am debugging / debugging lines of code with the "F8" key, depending on the function it enters, instead of going to the next line, the command runs until the end, as if it had pressed the "F5" key".

You’re not doing this in just one code, but in all the macros that I have.

Someone gets help?

  • Hi Thiago! How are you? Could you give an example of a code in which this is occurring? This can vary greatly from case to case, but in general, the debugger jumps to the end or to a next instruction when the conditions it "jumps" are not true. For example, in an "IF" clause with a condition that returns False, the debugger goes straight to the "End if" and executes the following statement.

  • Hi André, all right? Follow an example "Sub Clear() Sheets("Base1"). Select Ult = Cells(Rows.Count, 1). End(xlUp). Row If Ult > 1 Then Range("A2:BI" & Ult). Select Selection.Delete End If Sheets("Base2"). Select Ult = Cells(Rows.Count, 1). End(xlUp). Row If Ult > 1 Then Range("A2:br" & Ult). Select Selection.Delete End If End Sub"

1 answer

0


Hello!

I tested the code sent, first, with the spreadsheet tabs with some filled cells. In this situation, the debugger traversed all lines.

Then I tested the same code without filling the cells and happened what I had put in the first comment: as this specific code erases the cells from row 2 to the last filled cell, if there is no filled cell, the IF condition becomes false and the debugger jumps directly to the End If.

It is not an Excel problem, on the contrary, it is even easier so to identify whether the conditions placed in the code are being executed or not.

  • Hi Andrea, very angry for the help! I checked here what happened, it’s working.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.