How to Transfer Specific Data from One Sheet to another Sheet through VBA in Microsoft Excel

Follow by Email

In this article you will learn how to transfer the specific data form one sheet to another, through VBA in Microsoft Excel.

We have data in range A:G columns, in which column A contains Name, column B contains Address, column C contains city, column D region, column E country, column F phone number and column G contains criteria.

image 1


From this data, we want to extract those candidate’s data who are not eligible, which we can find out in column G. To transfer the specific data from one sheet to another sheet in a workbook follow below given steps:-

  • Open VBA Page press the key Alt+F11

image 2


  • Double Click on Workbook in the list of VBA project

image 3


  • Then select workbook at the place of General
  • Write the below mentioned code:-


Private Sub Workbook_Open()

Dim i, Lastrow

Lastrow = Sheets("Sheet1").Range("A" & Rows.count).End(xlUp).Row


For i = 2 To Lastrow

If Sheets("Sheet1").Cells(i, "G").Value = "Not" Then

Sheets("Sheet1").Cells(i, "G").EntireRow.Copy Destination:=Sheets("Sheet2").Range("A" & Rows.count).End(xlUp).Offset(1)

End If

Next i

End Sub


image 4


Code Explanation:  First we have defined the variables, then we have given the definition of last row in the coding language of VBA, it will work for if data range is not decided than it will check last active range, and then will go in 2nd sheet and clear all the content from the sheet2. For i, we will define the range. And IF condition is used for define the condition, the data we want to pick and then paste in 2nd sheet.

  • To run the code press F5
  • Define data will get copied in the 2nd sheet

image 5

image 48

If you liked our blogs, share it with your friends on Facebook. And also you can follow us on Twitter and Facebook.

We would love to hear from you, do let us know how we can improve, complement or innovate our work and make it better for you. Write us at [email protected]

Please follow and like us:

Leave a Reply

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

To avoid automated spam,Please enter the value *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>