More Debugging Options Breakpoints

If you have hundreds of lines of code, you may not want to step through each line one by one. You may have a general knowledge that the problem is happening in one particular section of the program. In this case, you can set a breakpoint. You can then have the code start to run, but the macro breaks just before it executes the breakpoint line of code.

To set a breakpoint, click in the grey margin area to the left of the line of code on which you want to break. A large brown dot appears next to this code and the line of code is highlighted in brown (see Figure 2.23).

Figure 2.23

The large brown dot signifies a breakpoint.

Keyboard shorten*: Ctcl+i

Vorkboolca.OpeiiText FilenaBe:-"Ci\ Invoice t-t«". Orí «in

;*U7j ütaxtF.oví-1, PataTypei-Xisei Halted, TextGualltlers-XlDovlbleOuate , ConseeuclveDel linter ¡-False, Tab ¡«Drue, Sesiieoleo!-False, Canoa:-True , ^H«:>r*i«, ntMXBfo;-fcrr«v<*Er*p[i, i), l)

Array (J, 1), Arcar (4, Hi Arcey(5, U, Array(G, 1], Ar ray C?, 1]), 7railii.jllir.uj!;uiitsrs leet ion ■ Situ (» I Dcmn| -S* Panie["AH"| .Select Act lve-C*H. Toen«« U*IC1 « -TowJ" H.îiiî i"£Hn] .select

3e lection .ForaHaniC! " «-3HHtH[-i2K;Rf-no "_

9« iectioa.ro«. »old - Ttue Row5("H:H") .Select Seitcttosí»Tost-Sold * True CtlM.Xlt«

3e lection. Coiunaa - AiwoFlt

Now, from the menu select Run, Run Sub or press F5. The program quickly executes but stops just before the breakpoint. The Visual Basic Editor shows the breakpoint line highlighted in yellow. You can now use F8 to begin stepping through the code (see Figure 2.24).

Figure 2.24

The yellow line signifies that the breakpoint line is about to be run next.

Kcytooftfd SSioctcut: Ctel+i

ïarkbooJcs.Ope&TeKt Filenane:-

invoioc.Mt". Orsatn

StartRov: -1, l'acaType: -xlDeiiisiced, TextCruaïifierr-xlDaubleCruiite _ , Con*eo«ivt®etin.uee :-r«l*c, Tnb:«Tsue, 3e«Acoloa!*r*l:îCi CooM:»Truc ~ , Upaceï-Kaiae, Cttver !-t'alae, FleldIi>Io;-Array |Array(l, 3), Arrayl.3, 1), ArcayOr 11. Artayd, Il, Arcay'jS, 11, Arcay($, 11, Arcay(7, 1|], Tea&llniiKiauNuHfeers :-tr u*

Select ion. End(xlOovn) .Select RU0t<"A14") -SeJtct ActiveCeii.rocnMiafiiCi - "Total" Panne nii"! .Select a* ieCt tOtt. tOtmu )» ICI » "»$U*(Jl(-lt)<:*|-l)C] * Hscl«rtIon.AutoFill Destination:-Range ("EU :GH-t, Type:-xirillDefnuit Bnaiïc fin i Cil") i Select Kova[-1;1").Select Seleetion.Fonç.Eoid • True

Selection.Font.Bold - True Ce Uo.Select

3e leetio». Colomba. Aiitont End aua_

0 0

Post a comment