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

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
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,994
Messages
6,122,633
Members
449,092
Latest member
bsb1122

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