If cell in Column e = B copy next 32 rows to sheet2 then loop

jnbrewer69

New Member
Joined
Jun 12, 2007
Messages
10
Hi,
Thanks in advance to all you good guys and gals.

I need a macro that will look down Sheet1 column E
Find the first cell that contains "B"
Then count down 32 rows and copy the 32 rows to sheet2.

Then loop down sheet1 column E find the Next "B"

Then count down 32 rows and copy the 32 rows to sheet2.Below the previous copied rows

Then continue till the end of the sheet.

Hope that makes sense

Johnny B
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Not perfect but may give you some help?

Code:
Dim c As Range, firstaddress As String
Dim rngPaste As Range
With Worksheets(1).Columns(5)
    Set c = .Find("B", LookIn:=xlValues, lookat:=xlWhole)
    If Not c Is Nothing Then
        firstaddress = c.Address
        Do
            Set rngPaste = Sheets("Sheet2").Cells(Rows.Count, 5).End(xlUp).Offset(1, -4)
            .Rows(c.Row + 1 & ":" & c.Row + 32).EntireRow.Copy rngPaste
            Set c = .FindNext(c)
        Loop While Not c Is Nothing And c.Address <> firstaddress
    End If
End With
 
Upvote 0

Forum statistics

Threads
1,214,639
Messages
6,120,679
Members
448,977
Latest member
dbonilla0331

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