Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ibrahimhammani/ee3ee0777d86c0c01db2672209b0ca9f to your computer and use it in GitHub Desktop.
Save ibrahimhammani/ee3ee0777d86c0c01db2672209b0ca9f to your computer and use it in GitHub Desktop.
Copeing from Source sheet to destination Sheet,The column B is The ID in both Sheets, So we copy the column from the column I of source sheet
'Copeing from Source sheet to destination Sheet
'The column B is The ID in both Sheets
'So we copy the column from the column I of source sheet
'To the column I of Destination sheet
Sub copyCells()
'Destination sheet
Set destSheet = Sheets("Feuil1")
'Source Sheet
Set srcSheet = Sheets("Feuil2")
Dim i
Dim j
'Start from row 2, row 1 is the title
i = 2
'While we still have IDs to compare with, in destination B column
Do Until IsEmpty(destSheet.Range("B" & i))
'Start from row 2, row 1 is the title
'for each iteration we look for the ID in the src Column
j = 2
'We look for the destination ID in all row or=f the source column
Do Until IsEmpty(srcSheet.Range("B" & j))
'if ID in source equals ID in destination, we copy The I row
If destSheet.Range("B" & i).Value = srcSheet.Range("B" & j).Value Then
destSheet.Range("I" & i).Value = srcSheet.Range("I" & j).Value
End If
'Go to next row in source sheet
j = j + 1
Loop
'Go to next row in destination sheet
i = i + 1
Loop
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment