need help

I have one excel issue that I am trying to find a solution.

I have two spreadsheets, I want to compare column A in spreadsheet1 with
column A in spreadsheet2. Only if product code in both columns A match, then I want to change data in their rows, in columns
C and F, so the spreadsheet1 will import data from spreadsheet2, from column D to column F and from column E to column C. If products in columns A do not match, do nothing about it, only in columns that matched.

I attached this file here.
can anyone PLEASE help me in this?


Cut and paste this into a VBA module

''' This routine requires a reference to the Microsoft scripting runtime
Sub doData()

''' Firstly we create the range containing the data on the foreign spreadsheet
Dim source As Range
Dim sourceCell As Range
Set source = Workbooks("Book2").Sheets("Sheet1").Range("A1:A10")

''' We now create a dictionary to store the unique values in the foreign sheet
''' Note we are only using the keys not the values in the dictionary.
''' There may be more efficient data structures in which to do this but to the
''' best of my knowledge VBA doesn't provide them
Dim sourceData As Dictionary
Set sourceData = New Dictionary

''' We now loop through the source data populating the dictionary
For Each sourceCell In source
''' If you can GUARENTEE that there are no duplicates in the
''' source data then is line can be omitted
If sourceData.Exists(sourceCell.Text) = False Then
sourceData.Add sourceCell.Text, 0
End If
Next sourceCell

''' Create the range containing the target data
Dim target As Range
Set target = Range("Sheet1!A1:A51")
Dim targetCell As Range

''' TRUE if the value is in the dictionary
Dim isThere As Boolean

''' Loop through all the cells in the target range
For Each targetCell In target
''' TRUE if the cell in a key in the dictionary
isThere = sourceData.Exists(targetCell.Text)
''' If the value is there then print 'There' 3 columns to the left
If isThere = True Then
Range(targetCell.Address).Offset(0, 3).Value = "There"
''' Otherwise print 'Not There'
Range(targetCell.Address).Offset(0, 3).Value = "Not There"
End If
Next targetCell

End Sub

Almir's picture

need help

Miraleme (mozemo i na nasem),

I would try =IF(first A = second A;make changes;do nothing)



hvala Almire, ali je ti jos

hvala Almire, ali je ti jos uvijek komplikovano za mene, mogu li ti se nekako javiti, imas li vremena ?

Almir's picture

Have you checked your mail?

I have sent solution. Check it up.

Almir's picture

Javi se na mail