A little VB help please

kylefraney

Board Regular
Joined
Mar 21, 2003
Messages
127
I create a parameter query and created several macros. I need a little code to run the macro upon the exiting of a specific cell. Basically after the user enters data into a cell I need a refresh of a pivot table.

Thanks
 

Some videos you may like

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

Jonmo1

MrExcel MVP
Joined
Oct 12, 2006
Messages
44,061
Private Sub Worksheet_Change(ByVal Target As Range)
Dim KeyCells As Range

' The variable KeyCells contains the cells that will
' cause an alert when they are changed.
Set KeyCells = Range("g4")

If Not Application.Intersect(KeyCells, Range(Target.Address)) _
Is Nothing Then

' Run a macro when cell is changed.
Application.Run _
"macroname"
End If
 

kylefraney

Board Regular
Joined
Mar 21, 2003
Messages
127
Alright, now the macro is running faster then the parameter query. I now need to insert a 3 second delay before the macro kicks off.
 

Jonmo1

MrExcel MVP
Joined
Oct 12, 2006
Messages
44,061
Private Sub Worksheet_Change(ByVal Target As Range)
Dim KeyCells As Range

' The variable KeyCells contains the cells that will
' cause an alert when they are changed.
Set KeyCells = Range("g4")

If Not Application.Intersect(KeyCells, Range(Target.Address)) _
Is Nothing Then

'Wait 3 seconds
Application.Wait Now + TimeValue("00:00:03")

' Run a macro when cell is changed.
Application.Run _
"macroname"
End If
 

Watch MrExcel Video

Forum statistics

Threads
1,113,848
Messages
5,544,640
Members
410,627
Latest member
georgealice
Top