justdriving
10-07-2011, 12:16 PM
Hi,
I wanted to copy cells from Sheet2 - Col A, B and D and paste it in Sheet1 - Col A, B and D.
I will perhaps prefer this method: -
Find end_of_row in COl A of Sheet1
Find end_of_Col in Row 1 of Sheet1
Run loop from 2 to end_of_row
Select A(LoopValue) from Sheet2, copy it
Find A(LoopValue)'s value in Col A of Sheet1.
If found, then
If AND (Sheet1.B(LoopValue).value = Sheet2.B(LoopValue).value, Sheet1.D(LoopValue).Value = Sheet2.D(LoopValue).value) then
I will paste Sheet2.A(LoopValue).value, Sheet2.B(LoopValue).value and Sheet2.D(LoopValue).value into Sheet1.A(end_of_row+1), Sheet1.B(end_of_row+1) and Sheet1.D(end_of_row+1), Sheet1.(end_of_row+1, end_of_col+1) = "Duplicate" respectively.
Else
I will paste Sheet2.A(LoopValue).value, Sheet2.B(LoopValue).value and Sheet2.D(LoopValue).value into Sheet1.A(end_of_row+1), Sheet1.B(end_of_row+1) and Sheet1.D(end_of_row+1)
End If
End If
End Loop
Condition 2: Font = Red in those rows which have "Duplicate" values.
I have difficulty in converting above algorithm to VBA program. I am looking for expert opinion.
There could be a better way to make this program. Looking to learn from experts in this forum.
I may modify or add some other conditions later. :stars:
I wanted to copy cells from Sheet2 - Col A, B and D and paste it in Sheet1 - Col A, B and D.
I will perhaps prefer this method: -
Find end_of_row in COl A of Sheet1
Find end_of_Col in Row 1 of Sheet1
Run loop from 2 to end_of_row
Select A(LoopValue) from Sheet2, copy it
Find A(LoopValue)'s value in Col A of Sheet1.
If found, then
If AND (Sheet1.B(LoopValue).value = Sheet2.B(LoopValue).value, Sheet1.D(LoopValue).Value = Sheet2.D(LoopValue).value) then
I will paste Sheet2.A(LoopValue).value, Sheet2.B(LoopValue).value and Sheet2.D(LoopValue).value into Sheet1.A(end_of_row+1), Sheet1.B(end_of_row+1) and Sheet1.D(end_of_row+1), Sheet1.(end_of_row+1, end_of_col+1) = "Duplicate" respectively.
Else
I will paste Sheet2.A(LoopValue).value, Sheet2.B(LoopValue).value and Sheet2.D(LoopValue).value into Sheet1.A(end_of_row+1), Sheet1.B(end_of_row+1) and Sheet1.D(end_of_row+1)
End If
End If
End Loop
Condition 2: Font = Red in those rows which have "Duplicate" values.
I have difficulty in converting above algorithm to VBA program. I am looking for expert opinion.
There could be a better way to make this program. Looking to learn from experts in this forum.
I may modify or add some other conditions later. :stars: