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.
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