Macro Testing - Running from a given point

JimM

Well-known Member
Joined
Nov 11, 2003
Messages
752
Hi all

Is there any way I can run a macro from a certain point rather than having to start from the begining each time ?

I know I could 'comment' all the code up to my start point but that means that when I uncomment it all afterwards I'll have to go through and re-comment all the lines that actually are comments ! (If that makes sense)

Thanks

Jim
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
This is rather unorthodox but you could use GoTo:

Code:
Sub example()
    GoTo whereToStart
    code
    whereToStart:
    more code
End Sub

DISCLAIMER: never use GoTo statements. very prone to errors, usually causing infinite loops, etc.
 
Upvote 0
It all depends on what the part of the code does that you wanna skip...
If the rest of the code relies on it, you will get in trouble anyway.

Or you could split up your code into functional blocks, and only run those blocks you need from within a separate sub. That way you can turn blocks of code on and off with just commenting one call, instead of the whole codeblock

By the way, commenting and uncommenting whole blocks of code is very easy. Just make sure you have the Edit toolbar visible. It has two buttons that do just that with all code you have selected...

Edit: I second moonfish: do NOT choose the GoTo option
 
Upvote 0

Forum statistics

Threads
1,224,537
Messages
6,179,408
Members
452,912
Latest member
alicemil

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