Run Macro Line by Line in Worksheet Module

Sahak

Well-known Member
Joined
Nov 10, 2006
Messages
1,008
Office Version
  1. 2016
  2. 2013
  3. 2011
  4. 2010
  5. 2007
Hi All,

How to run a macro one line at a time in Worksheet Module (Not Regular Module)

Thank you in advance
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Open the code and go to the first executable line
F9 will put a break there and when the code runs, it will stop and wait for you
Pressing F8 will 'step' through the lines
 
Upvote 0
Thank you veru much for reply.
What you suggesting that is for regular module, I was asking about worksheet module.
 
Upvote 0
I'm not certain that you can in the worksheet module.
However, why don't you copy it to a regular module and test it there, using Tweedles method
 
Upvote 0
Thank you Michael for reply.
I cant do that because Im using worksheet procedure like:
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
I must DoubleClick on Worksheet to test it
Or
Code:
 Private Sub Worksheet_Change(ByVal Target As Range)
or
Code:
 Private Sub Worksheet_SelectionChange(ByVal Target As Range)
 
Upvote 0
Sorry, I dont know about tweedle's method, Could you please explain?
 
Upvote 0
If you have something like this:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'//Check for duplicate project names on entry
'//and convert project name to uppercase.
    Dim intResponse As Integer
    Dim rng1 As Range, rng2 As Range, cell As Range, rng3 As Range, rng4 As Range
    On Error GoTo errTrap
    Application.EnableEvents = False
    If Not Intersect(Target, Columns(1)) Is Nothing Then
 
''''''more code'''''''
 
End sub

With tweedle suggestion ----- place your cursor on the first executable line, in this case it is On Erro GoTo errTrap, then press your F9 key.

A little spot will appear to the left and that line will turn a dark color. This is a Break Point.

(Ultimately, you could just place your Pointer in that margin to the left and L/Click)

Go back to your worksheet and type something in it and hit Enter. the code will stop on the Break Point waiting for YOU to step through it with F8.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,790
Messages
6,121,608
Members
449,038
Latest member
apwr

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