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?
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
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
 
Upvote 0
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)".
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,214,965
Messages
6,122,495
Members
449,088
Latest member
Melvetica

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