Hi
I am using following code to copy data by matching cell I want some addition in given below code, let me say that there is a given condition in code and if I say cell in G2:G is blank then code go to for each cell in range E2:E and match the cell Data!I:I.
And again if cell in E2:E then come back to G2:G.
Thanks in advance
I am using following code to copy data by matching cell I want some addition in given below code, let me say that there is a given condition in code and if I say cell in G2:G is blank then code go to for each cell in range E2:E and match the cell Data!I:I.
And again if cell in E2:E then come back to G2:G.
Code:
For Each cell In .Range("G2:G" & .Cells(.Cells(Rows.Count, 1).End(xlUp).Row, 1).Row)
If cell.Value = "" Then GoTo continue1
If IsError(Evaluate("=match(" & cell(1, 0) & ",Data!F:F,0)")) Then
Code:
Sub Button1_Click()
With Sheets("Result")
For Each cell In .Range("G2:G" & .Cells(.Cells(Rows.Count, 1).End(xlUp).Row, 1).Row)
If cell.Value = "" Then GoTo continue1
If IsError(Evaluate("=match(" & cell(1, 0) & ",Data!F:F,0)")) Then GoTo AddRow
yRow = Evaluate("=match(" & cell(1, 0) & ",Data!F:F,0)")
cell(1, 1).Copy
Sheets("Data").Cells(yRow, 7).PasteSpecial xlPasteValues, xlPasteSpecialOperationNone
cell(1, 2).Copy
Sheets("Data").Cells(yRow, 8).PasteSpecial xlPasteValues, xlPasteSpecialOperationNone
Application.CutCopyMode = False
GoTo continue1
AddRow: cell.Copy Sheets("Data").Cells(Cells(Rows.Count, 1).End(xlUp).Row + 1, 1)
continue1:
Next cell
End With
End Sub
Thanks in advance