Need a macro to copy rows only when certain columns are completely empty

profklein

New Member
Joined
May 20, 2017
Messages
20
Hello all
I am cleaning my data in stages. For my first stage, I want to eliminate all the rows where my survey participant did not answer any questions (meaning he or she wasn't truly a participant). I will know this if columns F through BK are completely empty. So what is need is this: Starting with row 3 in sheet x, I want to copy that row into sheet y as long as columns F through BK are not COMPLETELY EMPTY. I want to do this for every row until the last.

Thank you in advance for helping me with my PhD.

Gene
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Here is an untested VBA solution

Code:
Option Explicit
Sub Foo()
    Dim x As Worksheet
    Dim y As Worksheet
    Set x = Sheets("SheetX")
    Set y = Sheets("SheetY")
    Dim i As Long, lr As Long
    Dim lry As Long
    Application.ScreenUpdating = False
    lr = x.Range("B" & Rows.Count).End(xlUp).Row
    For i = 3 To lr
        lr2 = y.Range("A" & Rows.Count).End(xlUp).Row + 1
        If Application.WorksheetFunction.Count(Range("F" & i & ":BK" & i)) > 0 Then
            x.Range("B" & i).EntireRow.Copy
            y.Range("A" & lry).PasteSpecial xlPasteValues
        End If
    Next i
    Application.ScreenUpdating = True
    Application.CutCopyMode = False
    MsgBox "Completed"
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,333
Members
452,636
Latest member
laura12345

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