Help with look up and row paste

jedibrown

Board Regular
Joined
Oct 17, 2011
Messages
136
Hi,

Basically, I am creating some data and I am a bit stuck.

I would like to say:

If any cells in column c have the word "Giant" in it (there will be a sentance in each cell but I would like it to pick out the specific word) - Then please paste the whole line into sheet 2.

Is this possible?

Many thanks
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Try

Code:
Sub test()
Dim LR As Long, i As Long
LR = Range("C" & Rows.Count).End(xlUp).Row
For i = 1 To LR
    If LCase(Range("C" & i).Value) Like "* giant *" Then Rows(i).Copy Destination:=Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1)
Next i
End Sub
 
Upvote 0
Unfortunately - This doesn't seem to be working. I pasted it into VB within a command button.

Any ideas?

Thank you :)
 
Upvote 0
Press ALT + F11 to open the Visual Basic Editor, select Module from the Insert menu and paste in the code. ALT + Q to close the code window.

You can assign this to a Forms
 
Upvote 0
Sorry - I have also tried to run the module and it doesn't work either?

I have pasted

Sub test()
Dim LR As Long, i As Long
LR = Range("C" & Rows.Count).End(xlUp).Row
For i = 1 To LR
If LCase(Range("B" & i).Value) Like "Giant" Then Rows(i).Copy Destination:=Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1)
Next i
End Sub

Gone to Macro and ran test.
 
Upvote 0
Ok I have pasted this and ran it:

Sub test()
Dim LR As Long, i As Long
LR = Range("b" & Rows.Count).End(xlUp).Row
For i = 1 To LR
If LCase(Range("c" & i).Value) Like "* giant *" Then Rows(i).Copy Destination:=Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1)
Next i
End Sub

But it's only picking out 2 of the rows and there are lots more.
 
Last edited:
Upvote 0
Try this

Code:
Sub test()
Dim LR As Long, i As Long
LR = Range("C" & Rows.Count).End(xlUp).Row
For i = 1 To LR
    If InStr(Range("C" & i).Value, "giant") > 0 Then Rows(i).Copy Destination:=Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1)
Next i
End Sub
 
Upvote 0
Thanks - This is coming up with the following error though:

Run time error 12

Type Mismatch

Thanks again for your help with this one :)
 
Upvote 0

Forum statistics

Threads
1,217,365
Messages
6,136,127
Members
449,993
Latest member
Sphere2215

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