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
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
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
 
Upvote 0
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.
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,213,533
Messages
6,114,179
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top