using worksheet_calculate to copy an entire row if a 1 is found in a column

fuslela

New Member
Joined
Aug 12, 2020
Messages
23
Office Version
  1. 365
Platform
  1. Windows
Hello All,
I have a spreadsheet which needs to copy an entire row to a new sheet "Winners" should a "1" appear in column AA. So I a "1" appears in AA10 as an example, the whole of AA10 should be copied to sheet "winners", each time a calculation updates and a 1 is found, the whole row should be copied.
VBA Code:
Private Sub Worksheet_Calculate()
   If Application.CountIf(Range("AA2:AA50"), "1") > 0 Then
     a = Sheets("Winners").Cells(Rows.Count, "A").End(xlUp).Row + 1
'it breaks on the line below
target.EntireRow.Copy Destination:=Sheets("Winners").Range("A" & a)
     
 End If
End Sub

It fails with an error 424 object required.

Any ideas anyone?

Thanks!
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
I have also tried:

VBA Code:
Private Sub Worksheet_Calculate()
Dim rw As Long, Cell As Range
For Each Cell In Sheets(1).Range("AA2:AA50")
rw = Cell.Row
If Cell.Value = "1" Then
Cell.EntireRow.Copy
Sheets("Winners").Range("A" & rw).PasteSpecial xlPasteValues
End If
Next
End Sub

I get a runtime error 13 type - mistmatch error on the line
VBA Code:
If Cell.Value = "1" Then
 
Upvote 0
Solution

Forum statistics

Threads
1,214,591
Messages
6,120,428
Members
448,961
Latest member
nzskater

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