Copy corresponding row value

Closed
Pradeep Kumar V - Aug 24, 2009 at 06:20 AM
venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 - Aug 24, 2009 at 09:18 PM
Hello,

I have two worksheets sheet1 and sheet2, in sheet1 i have my data from Column A to D and formulas from E to Z
I am running below script which will look for value in Column V and If condition is met it will call macro Test1 and test2 based on if condition

Test1 will copy value from B1 of sheet1 and paste it to column B of sheet2 and
Test2 will copy value from B1 of sheet and paste it to column C of sheet2
"B1" data keeps changing
What I am looking is along with test1 and test2 macros I want to copy data from A20 to A50 which is corresponding to V20 to V50 from of Sheet1 to Sheet2

For E.g if the value of V30 is 41 then test1 macro will run. I want corresponding row value A30 to be copied to sheet2 column "A"

Sub Value1()
For Each c In Range("V20:V50")
If c.Offset(, 0) >= 40 Then Test1
If c.Offset(, 0) <= 40 Then Test2
Next c


End Sub
Sub Test1()
Worksheets("sheet1").Range("B1").Copy
Worksheets("sheet2").Cells(Rows.Count, "a").End(xlUp).Offset(1, 1).PasteSpecial xlValue
Application.CutCopyMode = False

Worksheets("sheet1").Range("A20:A50").Copy
Worksheets("sheet2").Cells(Rows.Count, "a").End(xlUp).Offset(1, 0).PasteSpecial xlValue
Application.CutCopyMode = False

End Sub
Sub Test2()
Worksheets("sheet1").Range("B1").Copy
Worksheets("sheet2").Cells(Rows.Count, "a").End(xlUp).Offset(1, 2).PasteSpecial xlValue
Application.CutCopyMode = False

Worksheets("sheet1").Range("A20:A50").Copy
Worksheets("sheet2").Cells(Rows.Count, "a").End(xlUp).Offset(1, 0).PasteSpecial xlValue
Application.CutCopyMode = False
Related:

1 response

venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 811
Aug 24, 2009 at 09:18 PM
when you debug the code (by successively hitting F8) in which code statement problem occurs and what is the error message?

one way of writing macro is RECORD the macro following the steps and then edit the macro
0