Having 2 Worksheets (UPDATED,CHANGES) each one have parameters in each column in variable order
UPDATED Worksheet has the columns:
Name / Value / Units
CHANGES Worksheet has the columns:
Status / Name / Value / Units
- So first I search in CHANGES a row with the Status: CHANGE
- Then I need to get the Name of that row
- To find it in UPDATED and copy the whole Row
- And copy it in the position after the column Status where the name was found
Each Name is unique but as I mentioned before has a variable position, my code so far:
Sub CopyRealChange()
Dim sh1 As Worksheet, sh2 As Worksheet
Dim lr As Long, r As Long, x As Long
Dim chng As Range
Set sh1 = ThisWorkbook.Worksheets("UPDATED")
Set sh2 = ThisWorkbook.Worksheets("CHANGES")
lr = sh2.Cells(Rows.Count, "A").End(xlUp).Row
x = 2
For r = 2 To lr
If Range("A" & r).Value = "CHANGE" Then 'Evaluate the condition.
'Sh2.Range("B" & x).Value = Sh1.Range("B" & r).Value 'Copy same Column location
'FIND
With Worksheets(2).Range("a1:a1000")
Set chng = .Find(sh2.Range("B" & x).Value, LookIn:=xlValues)
If chng Is Nothing Then
sh1.Range(c).EntireRow.Copy Destination:=sh2.Range("B" & x)
End If
End With
'FIND
End If
x = x + 1
Next r
End Sub
So thanks in advance for the help to resolve my problem
Concerns with the code show an error at this line (in the FIND)
sh1.Range(c).EntireRow.Copy Destination:=sh2.Range("B" & x)