Highlighted statements during code step through

Xmarksthespot

New Member
Joined
Jan 21, 2017
Messages
7
Using F8 to step through VBA code, each statement is highlighted as you step through the procedure. But if the code includes multiple statements on the same line only the first statement is highlighted. If there are , say, 4 statements on a particular line, then F8 must be pressed 4 times to get to the next line, but each press of F8 only highlights the first statement on the line. Is there any way to highlight each statement in turn on a multiple statement line?
 

igold

Well-known Member
Joined
Jul 8, 2014
Messages
2,458
Office Version
365, 2010
Platform
Windows
Hi,

I am using 2010 and when I step through either an If/Then statement or any multiple statement line , the editor always jumps to the section of code on the current line that it will execute next.

Could you provide me with a line of code that this happens with. I would like to see it in my editor.

igold
 

Xmarksthespot

New Member
Joined
Jan 21, 2017
Messages
7
For example in the middle of the procedure I have these lines of code:

Select Case IsNumeric(ActiveCell)
Case True
msg = "has number"
Case Else
msg = "has text"
When I use F8 to step through the procedure each of these statements are highlighted consecutively with each press of F8.

If I put the code on one line such as:
Select Case IsNumeric(ActiveCell): Case True: msg = "has number": Case Else: msg = "has text"
When I use F8 to step through the procedure when this section of the code is on one line only the first statement is highlighted ie- "Select Case IsNumeric(ActiveCell)".
 

igold

Well-known Member
Joined
Jul 8, 2014
Messages
2,458
Office Version
365, 2010
Platform
Windows
Thanks for the example. It must have something to do with the "Select" part of the statement. If you step through the code below, you will see the behavior that I have always seen.

Code:
Sub test()
    Dim msg As String
    Select Case IsNumeric(ActiveCell): Case True: msg = "has number": Case Else: msg = "has text"
    End Select
    Range("A1").Value = 100: Range("B1").Value = 200
End Sub
Seem like the more I learn the less I know, and unfortunately I do not have an answer to your question.

Thanks again.

igold
 

Forum statistics

Threads
1,085,542
Messages
5,384,332
Members
401,887
Latest member
Somesh

Some videos you may like

This Week's Hot Topics

Top