Skip to main content

Excel Macro which copies one column to another by matching specific unique column

This is a simple Excel Macro which copy one column to another by comparing specific unique column. There two sheets: Sheet1 and Sheet2. We copy column 2 and 3 at Sheet2 to column 2 and 3 at Sheet1 by matching column 1 at both.

There might be persentage data. You should use NumberFormat parameter in that situation.

Sub CopyCells()
    '*** Defining variables ***'
    Dim Value1, Value2
    Dim RowsCount1, RowsCount2

    '*** Find out rows count ***'
    RowsCount1 = Worksheets("Sheet1").Range("A1").CurrentRegion.Rows.Count
    RowsCount2 = Worksheets("Sheet2").Range("A1").CurrentRegion.Rows.Count

    '*** Copying data ***'
    For C1 = 2 To RowsCount2
Set Value1 = Worksheets("Sheet2").Cells(C1, 1)
For C2 = 3 To RowsCount1
Set Value2 = Worksheets("Sheet1").Cells(C2, 1)
If Value1 = Value2 Then
                Worksheets("Sheet1").Cells(C2, 2) = Worksheets("Sheet2").Cells(C1, 2)
                Worksheets("Sheet1").Cells(C2, 2).NumberFormat = "0.00%"
                Worksheets("Sheet1").Cells(C2, 3) = Worksheets("Sheet2").Cells(C1, 3)
                Worksheets("Sheet1").Cells(C2, 3).NumberFormat = ""
            End If
        Next C2
    Next C1
End Sub

C1 and C2 mean Counter1 and Counter2.

How to synchronize Google Calendar and Outlook?

If you want to sync Google Calendar and Outlook, Google Calendar Sync tool is all you need. There are 2-way and 1-way synchronizing alternatives. Try it:

Google Calendar Sync tool

If you have Google Apps for Business (I mean you pay for the service), you can use an excellent tool that name is Google Apps Sync for Outlook. It provides mail, calendar, contact, free/busy data syncronization capability.

Lastly, if you are bored of Outlook (How can it be possible?!) and want to move whole data to Google Apps, Migration Tool is for you: