Advertisement

04.14.2008 at 01:53PM PDT, ID: 23321802
[x]
Attachment Details

Excel Macro To Copy Rows to Other Worksheets, Based On A Cell Value

Asked by Tosagua in Microsoft Excel Spreadsheet Software, VB Script

Excel Macro To Copy Rows to Other Worksheets, Based On A Cell Value

This is a second attempt to resolve this problem, from a different approach. We want to copy all rows in the first worksheet, with a specific value in Range (E5:E) to the respective - pre-existing - worksheet in the same workbook.

Previously, we copied ALL of the rows and pasted them into each worksheet. Then we went through each worksheet and deleted the rows that did not belong. There are ~6,000 to 10,000 rows and 20 worksheets. The macro takes HOURS to run. We need to avoid the looping code that needs to review each row, in each worksheet. Code is listed below.

We aslo included an illustration of what we are trying to do, and a scaled down workbook with sample data.

Any Code, Ideas, Insight, Suggestions, Warnings, or whatever would be greatly appreciated.

Thank you,

TosaguaStart Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
Current Row Delete Code:
 
   Sheets("1250 - BADGER DR").Select
 
    On Error Resume Next
'
iRow = 4
 
'Find last row and column
iLastRow = Columns(5).Find(What:="*", SearchDirection:=xlPrevious, _
      SearchOrder:=xlByRows).Row
 
Do While iRow <> iLastRow
    iRow = iRow + 1
    If Cells(iRow, 5) <> "1250" Then
        Rows(iRow).EntireRow.Delete
        iRow = iRow - 1
        iLastRow = iLastRow - 1
    End If
    
Loop
    Range("P2").Select
Attachments:
 
Screenprint Illustration - Copy Rows To New Worksheets
 
 
Copy Rows To New Worksheets
 
[+][-]04.14.2008 at 03:05PM PDT, ID: 21354366

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Microsoft Excel Spreadsheet Software, VB Script
Sign Up Now!
Solution Provided By: StellanRosengren
Participating Experts: 2
Solution Grade: A
 
 
[+][-]04.14.2008 at 05:14PM PDT, ID: 21355075

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628