VBA Problem - Copying Rows Based on Specific Text and Pasting to New Worksheet

MIexcelNovice

New Member
Joined
Dec 17, 2014
Messages
15
Hi All,

This problem seems really simple in theory, but I'm very new to VBA so I've been trying to use past suggestions to similar problems and work from there but haven't been able to get very far.

Basically, I need a way to identify rows off of a main worksheet called Lockbox 223064 based on specific names that are in column "I" (Omaha is the name used in the code below) . Then I need those entire rows that are copied to be pasted into a new worksheet with a specific name (the name of the worksheet is also called Omaha ​ in the example below).

I have used the following code to get me started towards what I am looking for:

Sub Copy_Paste()
Dim LR As Long, i As Long
With Sheets("Lockbox 223064")
LR = .Range("I" & Rows.Count).End(xlUp).Row
For i = 1 To LR
With .Range("I" & i)
If .Value Like "*Omaha*" Then .EntireRow.Copy Destination:=Sheets("Omaha").Range("A" & Rows.Count).End(xlUp).Offset(1)
End With
Next i
End With
End Sub

- This code will work for me. However, there are multiple names that I need to use to identify rows by (for example besides Omaha, any rows containing Woodmen, GPM Life, or United World Life in column "I" need to be copied to this specific worksheet as well)

If anyone can help me or suggest another way about this I would be greatly appreciative. Someone recommended using an autofilter code to filter by these names and then copy the results. However, I couldn't get the code to copy only the results for some reason.

Thanks in advance
 
Last edited:

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

Forum statistics

Threads
1,224,550
Messages
6,179,462
Members
452,915
Latest member
hannnahheileen

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