Simple Macro Not Firing

rob51852

Board Regular
Joined
Jun 27, 2016
Messages
190
Office Version
  1. 2016
Platform
  1. Windows
Hi guys,

I am trying to write a macro to copy/paste cells when a formula in AC5 = 60.

I have put this code in the worksheet:

VBA Code:
Private Sub Worksheet_Calculate()
If Range("AC5") = "60" Then Call Capture
End Sub

And this code in a module:

VBA Code:
Sub Capture()
   Application.ScreenUpdating = False
   
   With ThisWorkbook.Worksheets("Market").Range("Y5:Y34").Copy
      ThisWorkbook.Worksheets("Market").Range("Z5").PasteSpecial Paste:=xlPasteValues
   End With
   
   Application.CutCopyMode = False

   Application.ScreenUpdating = True
End Sub

But it is not firing when AC5 = 60.

Can anyone see what I'm doing wrong?

Thanks
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Hi there. Try removing the quotes - as written it is looking for text.
VBA Code:
       Private Sub Worksheet_Calculate()
If Range("AC5") = 60 Then Call Capture
End Sub
 
Upvote 0
You're welcome and thanks for the feedback. My brain works (or doesn't) like that a lot of the time!
 
Upvote 0

Forum statistics

Threads
1,214,912
Messages
6,122,200
Members
449,072
Latest member
DW Draft

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