Hi
help me with my requirement, I have data in one excel sheet2 and I have created a button with macro, once i execute/run the macro it should copy and paste the data to sheet1 and i wanted to show this data from particular row(let's take A12). I am not sure that i am using right approach or not, Below the code I am using.
Sub pendingcopy()
Dim lastrow As Long, erow As Long
Sheets("Sheet1").Range("A1:D10000").Clear
lastrow = Sheet2.Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To lastrow
If Sheet2.Cells(i, 6) = "Pending" Then
Sheet2.Cells(i, 3).Copy
erow = Sheet1.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
Sheet2.Paste Destination:=Worksheets("Sheet1").Cells(erow, 1)
Sheet2.Cells(i, 5).Copy
Sheet2.Paste Destination:=Worksheets("Sheet1").Cells(erow, 2)
Sheet2.Cells(i, 7).Copy
Sheet2.Paste Destination:=Worksheets("Sheet1").Cells(erow, 3)
End If
Next i
Application.CutCopyMode = False
Sheet1.Columns().AutoFit
Range("A10").Select
End Sub
help me with my requirement, I have data in one excel sheet2 and I have created a button with macro, once i execute/run the macro it should copy and paste the data to sheet1 and i wanted to show this data from particular row(let's take A12). I am not sure that i am using right approach or not, Below the code I am using.
Sub pendingcopy()
Dim lastrow As Long, erow As Long
Sheets("Sheet1").Range("A1:D10000").Clear
lastrow = Sheet2.Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To lastrow
If Sheet2.Cells(i, 6) = "Pending" Then
Sheet2.Cells(i, 3).Copy
erow = Sheet1.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
Sheet2.Paste Destination:=Worksheets("Sheet1").Cells(erow, 1)
Sheet2.Cells(i, 5).Copy
Sheet2.Paste Destination:=Worksheets("Sheet1").Cells(erow, 2)
Sheet2.Cells(i, 7).Copy
Sheet2.Paste Destination:=Worksheets("Sheet1").Cells(erow, 3)
End If
Next i
Application.CutCopyMode = False
Sheet1.Columns().AutoFit
Range("A10").Select
End Sub