View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
JLGWhiz JLGWhiz is offline
external usenet poster
 
Posts: 3,986
Default How to set up a delay to Private Sub Worksheet_Change(ByVal Target

To increase or decrease the time of delay, change the s = Timer + # line.
The # is measured in seconds, currently at .5 (1/2) second.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$J$245" Then
s = Timer + 0.5
Do While Timer < s
DoEvents
Loop

(my macro code)


End If
End Sub


"gordom" wrote:

Hi,
I have a sheet with a pivot table. The data from pivot table report are
modified and imported to another range of cells. The layout of this
cells is changed by macro. If I triggered the macro manually it works
fine. The problem starts if I want to execute the macro automatically
when one of the cells is changed (I use "Private Sub
Worksheet_Change(ByVal Target As Range)" event). Unfortunately macro
corrupts data in that case. I suppose that macro starts modifying the
layout before all data are fully imported from the pivot. I tried to set
up some delay to the event but couldn't figure out how to do so. Could
you please help me? Thanks in advance.
gordom



my code syntax

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$J$245" Then


(my macro code)


End If
End Sub