Copy incomplete data to a new sheet using VBA in Microsoft Excel


In this article, we will create a macro to copy incomplete data to a new sheet.

Raw data for this article consists of salary data, which includes some incomplete records.





We want to copy the records of those employees whose salary details are missing. Clicking the button will move incomplete records to “BlankRecords” sheet.


Logic explanation

In this article, we have created “CopyEmptys” macro to copy missing records to “BlankRecords” sheet. It checks the Salary column for blank records. If a blank record is encountered, then it copies that record to “BlankRecords” sheet.

Code explanation

intRowL = Cells(Rows.Count, 1).End(xlUp).Row

Above code is used to get row number of last cell.

IsEmpty(Cells(intRow, 4))

Above code is used to check whether mentioned salary is empty.

.Range(.Cells(intRowT, 1), .Cells(intRowT, 3)).Value = Range(Cells(intRow, 1), Cells(intRow, 3)).Value

Above code is used to have a copy of missing record from the main sheet to “BlankRecord” sheet.


Please follow below for the code

Option Explicit

Sub CopyEmptys()

'Declaring variables
Dim intRow As Integer, intRowL As Integer, intRowT As Integer

'Getting row number of last cell
intRowL = Cells(Rows.Count, 1).End(xlUp).Row

'Looping from 10th row to last cell
For intRow = 10 To intRowL
    'Checking the fourth column whether it is empty
    If IsEmpty(Cells(intRow, 4)) Then
        With Worksheets(2)
            'Getting row number of row next to last row
            intRowT = .Cells(.Rows.Count, 1).End(xlUp).Row + 1
            'Inserting data to "BlankRecords" sheet
            .Range(.Cells(intRowT, 1), .Cells(intRowT, 3)).Value = _
            Range(Cells(intRow, 1), Cells(intRow, 3)).Value
        End With
    End If
Next intRow

End Sub


If you liked this blog, share it with your friends on Facebook. Also, you can follow us on Twitter and Facebook.

We would love to hear from you, do let us know how we can improve our work and make it better for you. Write to us at

Leave a Reply

Your email address will not be published. Required fields are marked *

Terms and Conditions of use

The applications/code on this site are distributed as is and without warranties or liability. In no event shall the owner of the copyrights, or the authors of the applications/code be liable for any loss of profit, any problems or any damage resulting from the use or evaluation of the applications/code.