Search Range for Value, Copy Whole Row if Found

burger

New Member
Joined
Nov 9, 2016
Messages
2
Hi,

I'm very new to VBA and have tried to solve this (have read many threads here) in the last couple of days but have not been able. I hope you fine folks are willing to point out where I'm going wrong.

Context:
I've got a spreadsheet with items in rows 5-713 down column B(merged up to cell J) where for each date (Columns K-SP) the item is scored either a 1 or a 0. My goal is to create a list at the bottom of the worksheet that contains all items which have gone from 1 to 0. To start, I've simply been trying to get my "generate list" button to copy all rows with a 0 in them to the bottom, figuring I would tweak it later to do exactly what I wanted. I've tried several things and gotten several different errors.

Here is my code so far, and (I think) the closest I've come.

Code:
Private Sub CommandButton1_Click()

Dim y As Integer, z As Integer

y = 5
z = 714

Do Until y = 713
    If Range("By:SPy").Value = 0 Then Range("By:SPy").Copy Range("Bz")
    y = y + 1
    z = z + 1

Loop
   

End Sub

The error I get with this attempt is "out of memory". Several other attempts have given me "method 'range of object' _Worksheet failed".

Any help to figure out this first step, or even how to have it scan for 1's that turn to 0's would be wonderfully appreciated. I'm sure I'm missing something simple and hope you guys can forgive my ignorance of all things coding.

Thanks!
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Sorry to double post, but I was checking up on the posting guidelines and it looks like I left out a bit of information that is appreciated here.

This is in Excel 2010, on Windows.

Here is a sample table to represent what I tried to describe in the 'context' section above. Sorry it is not as pretty as some of the ones around here, I could not quite figure out how with the in-built tables:


1A-JKLMNOPQ...SP
2infodatedatedatedatedatedatedate...date
3infoinitialsinitialsinitialsinitialsinitialsinitialsinitials...initials
4infoageageageageageageage...age
5item 11111011...1
6item 21111111...1
7item 31111111...1
.................................
713item 7130000110...1

<tbody>
</tbody>
 
Upvote 0

Forum statistics

Threads
1,216,193
Messages
6,129,447
Members
449,509
Latest member
ajbooisen

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