finding all values in a sheet less than stated cell and pasting

robjowens

Board Regular
Joined
Sep 26, 2009
Messages
102
Hi Peeps,

How would I go about amending the below to paste all values below the cell D21 in the Beacon Data sheet.

Cheers,
rob

PHP:
Sub CandidateList()
With Worksheets("Results").Range("TotalNPV")
Set c = .Find(Worksheets("Beacon Data").Range("D21").Value, LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.EntireRow.Copy Destination:=Worksheets("Candidate List").Range("a" & Worksheets("Candidate List").Range("a64000").End(xlUp).Row + 1)
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
End With
Sheets("Candidate List").Select
End Sub
 

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.
Hi Rob,

Your current code is doing a .Find and .FindNext for a single value.
If you want to find all values that meet a criterion -in this case "Less than D21",
then you would be better off using something other than .Find and .FindNext.

I'd suggest you take the approach of using Advanced Filter to copy only the rows that meet your criterion.

You can find example code on this Board.

Just ask if you need some help getting that approach to work with your specifics.
 
Upvote 0
thanks, i worked this out after about 40mins of stressing and recorded a fresh macro using the advanced filter. will post for reference/search purposes when i'm next in the office.
 
Upvote 0

Forum statistics

Threads
1,224,570
Messages
6,179,610
Members
452,931
Latest member
The Monk

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