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

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

Forum statistics

Threads
1,172,048
Messages
5,878,891
Members
433,380
Latest member
Hadfield

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
Top