Match column between sheet, copy offset and combine duplicate

keyboard_jv

New Member
Joined
Jul 21, 2018
Messages
1
Hi, New in this forum, I am having a problem with my vba code, what i want is to match column from 2 different sheet,copy offset and sum up if matched values is greater than 1.

The problem with below codes, cannot sum up values if duplicate.
Thank you.

PHP:
Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
Dim lRow As Long       
Dim fValue As Range        
Dim n As Long
lRow = Sheet1.Range("A" & Rows.Count).End(xlUp).Row
For Each cell In Sheet1.Range("A1:A" & lRow)         
Set fValue = Sheet2.Columns("C:C").Find(cell.Value)          
If fValue Is Nothing Then GoTo NextCell
If cell.Offset(0, 1).Value = fValue.Offset(0, 3).Value And cell.Offset(0, 2).Value = "Layer1" Then
fValue.Offset(0, 2) = cell.Offset(0, 5)
ElseIf cell.Offset(0, 1).Value = fValue.Offset(0, 3).Value And cell.Offset(0, 2).Value = "Layer2" Then
fValue.Offset(0, 3) = cell.Offset(0, 5)
ElseIf cell.Offset(0, 1).Value = fValue.Offset(0, 3).Value And cell.Offset(0, 2).Value = "Layer3" Then
fValue.Offset(0, 4) = cell.Offset(0, 5)
End If
NextCell:Next cell
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Forum statistics

Threads
1,225,743
Messages
6,186,777
Members
453,370
Latest member
juliewar

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