Scan row for data, for every row with no data (from column b over) move data in column a to sheet 2

ExcelGuy13

New Member
Joined
Apr 17, 2016
Messages
3
So I have a sheet similar to the example below...the top few rows are populated with data specific to the report. Beneath that are user names in column A along with data in random columns adjacent to column A. I'm looking for VBA script that will essentially look at every row (in this example from row 7 down) and check to see if there is any information in the row (aside from column a). If there is anything in any column for that row, it will ignore it and move to the next row. For every instance that there is no data to the right of column A, it should copy the data in that row from Column A and move it to sheet 2. In this example everybody has data to the right of column A except Eric and Marilyn, so only Eric and Marilyn are moved to sheet 2. Can anybody assist with this request?

hX2Z0Ld.png


nxfgmrC.png
 
Try this:
Code:
Sub Columns_Me()
Application.ScreenUpdating = False
Dim i As Long
Dim Lastrow As Long
Dim Lastrowa As Long
Dim LastColumn As Long
Lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Lastrowa = Sheets(2).Cells(Rows.Count, "A").End(xlUp).Row + 1

    For i = 7 To Lastrow
        LastColumn = Cells(i, Columns.Count).End(xlToLeft).Column

            If LastColumn < 2 Then
                Rows(i).Copy Destination:=Sheets(2).Rows(Lastrowa)
                Lastrowa = Lastrowa + 1
            End If
    Next
Application.ScreenUpdating = True
End Sub
 
Last edited:
Upvote 0

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