Irmann 0 Newbie Poster

hai and hello everyone,

1) I have done the macro that can automatically pull data between 2 sheet in the same workbook. The example below, just compare 2 cell and then pull the 4 data to other sheet if true. If i have 100++ data to compare between 2 sheet or workbook, it make my macro become unwieldy as the number of tests to make gets larger. Can anyone help me to solve this problem, make it (my macro) shortest as possible......


The macro is like this:-


Sub PullData()

If Worksheets("sheet1").Range("C2").Value = Worksheets("sheet2").Range("C2").Value Then

Worksheets("sheet1").Range("D2").Value = Worksheets("sheet2"). _ Range("D2").Value
Worksheets("sheet1").Range("E2").Value = Worksheets("sheet2"). _ Range("E2").Value
Worksheets("sheet1").Range("F2").Value = Worksheets("sheet2"). _ Range("F2").Value
Worksheets("sheet1").Range("G2").Value = Worksheets("sheet2"). _ Range("G2").Value
Else

Worksheets("sheet1").Range("D2:E2:F2:G2").Value = ""

End If

If Worksheets("sheet1").Range("C3").Value = Worksheets("sheet2"). _ Range ("C3").Value Then


Worksheets("sheet1").Range("D3").Value = Worksheets("sheet2"). _ Range("D3").Value
Worksheets("sheet1").Range("E3").Value = Worksheets("sheet2"). _ Range("E3").Value
Worksheets("sheet1").Range("F3").Value = Worksheets("sheet2"). _ Range("F3").Value
Worksheets("sheet1").Range("G3").Value = Worksheets("sheet2"). _ Range("G3").Value

Else

Worksheets("sheet1").Range("D3:E3:F3:G3").Value = ""

End If

End Sub


2) The example that i given to you is compare between 2 sheet in same workbook. Can anyone out there teach me how to compare between 2 workbook. Plz.... t.q

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.