VBA code for compare two columns in excel, and copy the difference at the bottom of column 2

lilloscar

New Member
Joined
Nov 27, 2016
Messages
37
This code do exactly what I need but I can't figure it out how to adapt it to my needs...
Please can you tell me how can I change this to work instead searching from A1:C and coping missing data to D1:F to work only comparing two columns J1:J and K1:K

Attach: https://www.4shared.com/s/fI0i45Uxyda

Code:
Option Explicit

Sub test()
    Dim a, i As Long, ii As Long, x As Range
    With Range("a1").CurrentRegion
        a = .Value: ReDim b(1 To UBound(a, 1) * 2, 1 To 3)
        With CreateObject("Scripting.Dictionary")
            .CompareMode = 1
            For i = 1 To UBound(a, 1)
                If a(i, 4) <> "" Then .Item(a(i, 4)) = Empty
            Next
            For i = 1 To UBound(a, 1)
                If Not .exists(a(i, 1)) Then
                    If x Is Nothing Then
                        Set x = Cells(i, 1).Resize(, 3)
                    Else
                        Set x = Union(x, Cells(i, 1).Resize(, 3))
                    End If
                End If
            Next
        End With
        If Not x Is Nothing Then
            x.Copy Cells(Rows.Count, 4).End(xlUp)(2)
            Set x = Nothing
        Else
            MsgBox "No new item"
        End If
    End With
End Sub
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Can you explain your problem precisely as your PC screen is not visible?

This code searches column D for blank cells and pastes A:C of the same row under the last row of column D. It seems to be doing something similar to filtering column D for blank cells and copying the visible cells from A:C and putting at bottom of column D.

What do you have in J1:J and K1:K and what is the expected outcom?
 
Upvote 0
For example, am not interested in the red columns, just want to know how to compare two columns (yellow), the first column A varies his data, and second column D register all the history and changes in A making a list, but I can't resolve how to move that columns (A and D) to other columns, for example J an K.

fetch
 
Upvote 0
Your screen is not visible, do you understand what that means?

Red column where? What is in columns J and K? Your spreadsheet is in front of you and nobody else.

Use an example to explain what you need the code to do. In your example use exact cell addresses, sheet names, etc.
 
Upvote 0
1- Your screen is not visible, do you understand what that means?

2- Red column where? What is in columns J and K? Your spreadsheet is in front of you and nobody else.

3- Use an example to explain what you need the code to do. In your example use exact cell addresses, sheet names, etc.

1- I don't know what you mean by screen not visible.

2- Red column in my attached image, and what is in J and K doesn't matter is the same data as the A and D (image), I attached in my first post the .xlsm file if you want to see it, so it is not only in front of me.

3- My example is in the image attached and my explanation.

I think you are annoyed of me, I have to repeat a common foreign phrase: "sorry for my bad English".
 
Upvote 0
@lilloscar
Some members cannot follow links due to security systems at work. Others wont follow links for safety reasons.
I looked at the link & there are a number of buttons marked "Download". Because of this very very few members will download your file, as they have no idea which is the correct button & which will download a load of adware/spyware/whatever.
 
Upvote 0
@lilloscar
Some members cannot follow links due to security systems at work. Others wont follow links for safety reasons.
I looked at the link & there are a number of buttons marked "Download". Because of this very very few members will download your file, as they have no idea which is the correct button & which will download a load of adware/spyware/whatever.


Thanks! Is any server that you recommend me to upload my .xlsm file?
 
Upvote 0
Here I uploaded to Dropbox
https://www.dropbox.com/s/bijusc3d2y7xq3h/Compare columns and copy missed data.xlsm?dl=0

@JackDanIce

I think is a great code, but I am not a programmer to know what I have to modify to use this on other columns like J and K, suppressing B, C, E and F results, I only need the A and D results in different columns.

I don't have any degree on this, I am a Civil Engeneer just trying to get things easier on my work, always I do a lot of taste, research and google, but this code is hard for me.
 
Upvote 0
Please supply the cross post links.
 
Upvote 0

Forum statistics

Threads
1,214,635
Messages
6,120,660
Members
448,975
Latest member
sweeberry

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