Copy specific rows and paste into new sheet

Microsoft Excel 2010
June 6, 2012 at 09:36:52
Specs: Windows 7, Intel 2.4GHz/8gigs
I am using excel 2010 on Windows 7 and I am trying to perform something I thought to be simple.

I would like to search each row for a specific identifier (YM), copy that row, and paste it on a new sheet. The identifiers I will be searching for are in the same column so searching by column would work as well.

I have done some searching and found what I thought was the exact answer to my question .
However when I set this macro up, it will execute but no data is copied to the next sheet. Any help would be greatly appreciated.


P.S. I have some programming exposure meaning I have tried a little tweaking of the parameters passed through code. That being said, I am clearly not very good at programming.

See More: Copy specific rows and paste into new sheet

Report •

June 6, 2012 at 10:29:03
To begin with, I don't like the code you provided the link for since the code is extremely inefficient because of it's use of Select.

Rarely, if ever, is there a need to Select a sheet or range in VBA in order to perfrom an operation on it.

For example, this section ...

'Select row in Sheet1 to copy
   Rows(CStr(LSearchRow) & ":" & CStr(LSearchRow)).Select

'Paste row into Sheet2 in next row
     Rows(CStr(LCopyToRow) & ":" & CStr(LCopyToRow)).Select

...could be condensed to:

' Copy/Paste Row From Sheet1 to Sheet2
    Sheets("Sheet1").Rows(CStr(LSearchRow)).Copy _

The condensed version simply does the Copy/Paste "internally" as opposed to "physically" selecting the Sheets and Ranges within the worksheets.

Take a look at Response # 3 of this thread and see if it leads you in the direction you want to go:

Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.

Report •

June 6, 2012 at 10:43:49
First off, thanks for the response. Secondly, I guess I am much more behind then previously stated. I flat out do not have the ability to execute this stuff on my own. Instead of posting other code I have found on the internet, I will just ask you. If you are not interested, no sweat and thanks for your time.

I would like to search for specific values in a row and display all the the results on a new sheet. Even 1 step further, I would like to find the rows by the initial value and then within those results, only paste those rows with an additional value in another column within the row. Make sense?


Report •

June 6, 2012 at 12:53:27
Please provide some specifics.

If you aren't able to modify the example code from the other threads, then anything I provide will have to work right out of the gate.

I can't offer anything unless I know what you are searching for, where you are searching for it, what you want copied and where you want it copied to.

If you are going to post any example data, please click on the following line and read the instructions found via that link.

Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.

Report •
Related Solutions

Ask Question