Find certain values, then copy part of the line to another sheet

KittyS

New Member
Joined
May 25, 2012
Messages
18
Hi,
I tried to make something to find a certain value (from a userform) in a range, and then copy the line partially to another sheet. Then go forth to the next found item and do the same. But... I cannot seem to make this loop. Anybody can advise...? :confused:

With Sheets("Data input").Range("N5:N1100")
Dim FoundRange As Range

Worksheets("Data input").Activate

For X = 1 To 1000

Set FoundRange = Sheets("Data input").Cells.Find(what:=Planweeknr.Value, LookIn:=xlValues, lookat:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If FoundRange Is Nothing Then
End
Else
FoundRange.Select
ActiveCell.Select
ActiveCell.Offset(0, 2).Range("A1").Select
Range(Selection, Selection.End(xlToLeft)).Select
Range(Selection, Selection.End(xlToLeft)).Select
Range(Selection, Selection.End(xlToLeft)).Select

ActiveCell.Activate
Selection.Copy

Sheets("Detail overzicht VAL").Select

Range("C5").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, -2).Range("A1").Select
ActiveSheet.Paste
ActiveCell.Select
ActiveWindow.SmallScroll Down:=6

End If

Next X

End With
Unload Me
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Hi,

I still can't manage with this. How do I put the FindNext with the scrolling down of the found items and COPY them?

Thx for your help!!
 
Upvote 0
It is difficult to see what range you want to copy. But it isn't necessary to select anything, for example

Code:
FoundRange.Copy Destination:=Sheets("Detail overzicht VAL").Range("C" & Rows.Count).End(xlUp).Offset(1)
 
Upvote 0
It is difficult to see what range you want to copy. But it isn't necessary to select anything, for example

Code:
FoundRange.Copy Destination:=Sheets("Detail overzicht VAL").Range("C" & Rows.Count).End(xlUp).Offset(1)

Hi,

Sorry for being unclear.. I want to copy not only the found field, but in that row also some cells to right and left of the found field..
and then move down to the next found field and copy the cells of that row etc.
 
Upvote 0
I can't work out what all that selecting is doing but you should be able to use Offset and Resize to specify the range to copy. For example

Code:
FoundRange.Offset(, -2).Resize(, 5).Copy Destination:=Sheets("Detail overzicht VAL").Range("C" & Rows.Count).End(xlUp).Offset(1)
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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