View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jan Karel Pieterse Jan Karel Pieterse is offline
external usenet poster
 
Posts: 535
Default Where to place code that changes a cell value?

Hi George,

I would like to know where to place my code, since placeing it in the module
section produces an error. The code is seen below. I need this code to
execute for the "current displayed" worksheet, but I do not believe that I
should copy it to ecery sheet, thats why I tried it in the modules.

Where should I put it to only have 1 location for the code?


It depends on when exactly you want to execute this code. If it is by clicking
a toolbar button or selecting a menu item, a normal module is fine. If it has
to be done because of a certain event (cell changed, other selection made), the
best place for it depends on for what sheets the event has to be done. If for
just one, it goes in the code module of that sheet, using the
Worksheet_SelectionChange or Worksheet_Change event. Otherwise it should go in
the thisworkbook module, using the Workbook_SheetSelectionChange or the
Workbook_SheetChange events.

Regards,

Jan Karel Pieterse
Excel MVP
http://www.jkp-ads.com