View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Alex J Alex J is offline
external usenet poster
 
Posts: 85
Default execute multiplication when data entry

Goepf,

To use the WorksheetChange function without looping, try this:

Private Sub Worksheet_Change(ByVal Target As Range)
Static lockout As Boolean

If lockout Then Exit Sub
lockout = True

'Make your calculations here

lockout = False

End Sub


The 'Static' declaration means that the program 'remembers' the value of the
variable [lockout] between runs of the routine. Making a calculation in this
routine, and writing it to the sheet WILL cause another Change event, as you
have found, which needs to be locked out.

You can also use another technique which will disable the change event.

Application.EnableEvents=False
' Make Calculations here
Application.EnableEvents=True

HTH,
Alex J


"goepf" wrote in message
...

I already tried the

Worksheet_SelectionChange
and
Worksheet_Change

functions but this ends eighter in a loop (calculate) or it changes my
cells always when I move from one to the other...

Any ideas???


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/

~~Now Available: Financial Statements.xls, a step by step guide to

creating financial statements