Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If you use Application.Wait, you are liable to wait, while nothing else
happens, including updating of the data. The Do While with DoEvents is a good approach. Another is to put the code you want to run into another routine, and use Application.OnTime to invoke it: Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address = "$J$245" Then Application.OnTime Now + TimeValue("00:00:10"), "CodeToRunSoon" End If End Sub In a regular module: Sub CodeToRunSoon() ' your code End Sub - Jon ------- Jon Peltier, Microsoft Excel MVP Peltier Technical Services, Inc. http://PeltierTech.com/WordPress/ _______ "ryguy7272" wrote in message ... Something like this: Application.Wait Now + TimeValue("00:00:10") So, it may evolve into: Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address = "$J$245" Then Application.Wait Now + TimeValue("00:00:10") (my macro code) End If End Sub -- RyGuy "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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Private Sub Worksheet_Change(ByVal Target As Range) | Excel Programming | |||
Private Sub Worksheet_Change(ByVal Target As Excel.Range) | Excel Programming | |||
Private Sub Worksheet_Change(ByVal Target As Excel.Range) | Excel Worksheet Functions | |||
Private Sub Worksheet_Change(ByVal Target As Range) | Excel Programming | |||
Private Sub Worksheet_Change(ByVal Target As Range) | Excel Programming |