Hi, I wonder whether somoene may be able to help me please.
I'm using the code below to compare columns on two sheets (1 column for each) and where there is a match, copy data from the 'Source' to 'Destination' sheet.
Sub IDEASSignals()
Dim Dic As Object
Dim Dn As Range
Dim Rng As Range
'This script adds the "Flexible Resource Signal".
With Sheets("All Resources")
'This is the column on the 'Source' sheet you are comparing to the 'Destination' sheet.
Set Rng = .Range(.Range("C8"), .Range("C" & Rows.Count).End(xlUp))
End With
Set Dic = CreateObject("scripting.dictionary")
Dic.CompareMode = vbTextCompare
For Each Dn In Rng
Set Dic(Dn.Value) = Dn
Next
With Sheets("IDEAS")
'This the column on the 'Destination' sheet you are comparing to the 'Source' sheet.
Set Rng = .Range(.Range("D8"), .Range("D" & Rows.Count).End(xlUp))
End With
For Each Dn In Rng
If Dic.exists(Dn.Value) Then
'The first offset is the 'Destination' sheet i.e. 11 columns from column D. The Second offset is the 'Source' sheet i.e. 4 columns from column C.
Dn.Offset(, 11).Value = Dic.Item(Dn.Value).Offset(, 4).Value
End If
Next Dn
End Sub
The code works fine, but I'd like to amend this, but I'm a little unsure about how to proceed.
The script currently compares column C on the 'Source' sheet with column D on the 'Destination' sheet and where a match is found copy column G from the 'Source' sheet and pastes this to column O on the 'Destination' sheet.
I'd still like to copy and paste the same columns, but I'd like to compare two columns from each sheet, so from the 'Source' sheet compare columns C and E to columns D and J on the 'Destination' sheet.
I just wondered whether someone could possibly look at this please and offer some guidance on how I may achieve this.
Many thanks and kind regards
Bookmarks