Shortcut way for indicating comments in block of code.

  • Thread starter Thread starter Hari
  • Start date Start date
H

Hari

Hi,

Sometimes I dont want to execute a long piece of code, lets say 15 to 20
lines of code in one block but I would like to execute rest of the code.

I will have to enter the comment indicator at the beginning of each of those
lines. Rather than doing that is there a shortcut way for treating only that
particular block of code as comment?

Regards,
Hari
India
 
Hi Hari

not sure if this is the easiest way but on the EDIT toolbar in VBA is an
icon to add the comment ' and one to remove it ... so select the block of
code, click on the add comment block icon (i always click 3 times to
distiguish between this & normal comments) and then when you want it to run
again, select it and click on the remove comment icon the appropriate number
of times.

Cheers
JulieD
 
Hari said:
Sometimes I dont want to execute a long piece of code, lets say 15 to 20
lines of code in one block but I would like to execute rest of the code.

I will have to enter the comment indicator at the beginning of each of those
lines. Rather than doing that is there a shortcut way for treating only that
particular block of code as comment?

Hi Hari,

If you display the Edit toolbar in the Visual Basic Editor you will see
two toolbar buttons on it called "Comment Block" and "Uncomment Block". If
you highlight a block of code and click the Comment Block button, that whole
block of code will be commented out. When you want to run that block of code
again, highlight it and click the Uncomment Block button to remove the
comments.

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *
 
Hi JulieD and Rob,

Thnx a lot for ur kind help.

(One doubt, the feature u indicated is there on my toolbar but Im not able
to find it in edit. I have excel 2002. Is this not part of menu in 2002.)

Regards,
Hari
India
 
Hi Hari

no, its only on the Edit Toolbar (view / toolbars / edit) not on the menu
anywhere (AFAIK).

Cheers
JulieD
 
It's not on the Edit Menu, but you could customize your menu, and add it
(Tools>Customize)
 
Back
Top