Copy/Paste Cells based on a condition

bowdown

New Member
Joined
Aug 19, 2016
Messages
5
Hello folks,

I have the following issue and will be very grateful if you provide some help:

I have one sheet which I need to manipulate some data and copy/paste from it (sample below):

I need a script which searches for the word 'Open' in column A and next finds the first non-empty cell in the same column A (in this case A19) and then copies everything below this cell (including A19) to a new sheet. In other words, I need to copy from A19 going down the whole sheet (both rows and colums) to a new sheet.

image.png
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Welcome to the Board!

Try this:
Code:
Sub bowdown()
Dim sSht As Worksheet, Fnd As Range, lR As Long
Set sSht = ActiveSheet
lR = Cells.Find(what:="*", searchorder:=xlByRows, searchdirection:=xlPrevious).Row
With sSht
    Set Fnd = .Range("A:A").Find(what:="Open", LookIn:=xlFormulas, lookat:=xlWhole)
    If Not Fnd Is Nothing Then
        Application.ScreenUpdating = False
        Set Fnd = Fnd.End(xlDown)
        .Range(Intersect(.Rows(Fnd.Row), .UsedRange), Intersect(.Rows(lR), .UsedRange)).Copy
        Sheets.Add after:=ActiveSheet
        With ActiveSheet
            .Range("A1").PasteSpecial Paste:=xlPasteAll
        End With
        sSht.Select
        Application.CutCopyMode = False
        .Range("A1").Select
    Else
        MsgBox "Open not found in column A"
    End If
End With
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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