Excel Macro - Start copy at rowX and repeat up to the end of table

Hello,

Now that my TXT files are imported, I need to build my Analysis Table as follow:

      For each tab that start by "ABC_"
                If cell A29 is not empty
                      Copy Cell A29 & B29 and paste it on the next empty Cell A in Tab "Analysis"
                      Copy Cell A30 & B30 and paste it on the next empty Cell A in Tab "Analysis"  
                                 and so on, until  the end of the table
                     

Hope this is kinda clear

/mld
mldaigle1Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rgonzo1971Commented:
Hi,

pls try

Sub macro()

For Each sh In ActiveWorkbook.Sheets
    If sh.Name Like "ABC_*" Then
        sh.Activate
        For Each c In Range(Range("A29"), Range("A" & Cells.Rows.Count).End(xlUp))
            c.Resize(1, 2).Copy Sheets("Analysis").Range("A" & Cells.Rows.Count).End(xlUp).Offset(1)
        Next
    End If
Next
End Sub

Open in new window

Regards
mldaigle1Author Commented:
Hi Rgonzo,

99% what i want.

For some reason, the macro copy the header locate in cell A28 & B28 on each "ABC_" tab.
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
Try this to see if you get the desired output.....
Sub CopyToAnalysis()
Dim ws As Worksheet, dws As Worksheet
Dim lr As Long

Set dws = Sheets("Analysis")

For Each ws In Worksheets
    If ws.Name Like "ABC_*" Then
        lr = ws.Cells(Rows.Count, "A").End(xlUp).Row
        If lr > 28 Then
            ws.Range("A29:B" & lr).Copy dws.Range("A" & Rows.Count).End(3)(2)
            Application.CutCopyMode = 0
        End If
    End If
Next ws
End Sub

Open in new window

Rgonzo1971Commented:
Or

Sub macro()

For Each sh In ActiveWorkbook.Sheets
    If sh.Name Like "ABC_*" Then
        sh.Activate
        If Range("A29") <> "" Then
            For Each c In Range(Range("A29"), Range("A" & Cells.Rows.Count).End(xlUp))
                c.Resize(1, 2).Copy Sheets("Analysis").Range("A" & Cells.Rows.Count).End(xlUp).Offset(1)
            Next
        End If
    End If
Next
End Sub

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mldaigle1Author Commented:
Thanks Expert,

This is working like a charm!

:)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.