• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Exporting Data

sasi251904

New Member
Hi All, i am sasi kanth. I wanted to copy data of required criteria from one excel sheet to another excel sheet. I have written the Following VBA code how ever there's an error persisting as "1004" Run time error. i am using Excel 2007(the code written is for a command button)can any one please help me on this.

x=2

do while (x,1)<> " "

if (x,4)>=20 then

worksheets("sheet1").rows(x).copy

worksheets("sheet2").activate

erow=activesheet.cells(rows.count,1).end(xlup).offset(1,0)

activesheet.paste destination:=woksheets("sheet2").rows(erow)

endif

worksheets("sheet1").activate

x=x+1

loop

end sub
 
Hi Sasi Kanth ,


I have no idea of what you want to do , but the following code does something ; see if it is what you want :

[pre]
Code:
Public Sub temp()
Dim erow As Long
x = 2
Worksheets("sheet1").Activate
With ActiveSheet
Do While .Cells(x, 1) <> ""
If .Cells(x, 4) >= 20 Then
.Rows(x).Copy
Worksheets("sheet2").Activate
erow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
ActiveSheet.Cells(erow, 1).PasteSpecial xlPasteAll
End If
Worksheets("sheet1").Activate
x = x + 1
Loop
Application.CutCopyMode = False
End With
End Sub
[/pre]
Narayan
 
Hi Narayan & Patnaik, Thank you for the reply. I just want to copy a range of data with a certain criteria from one excel sheet to other excel sheet. And i have written the above code How ever its working now. I just wanted to know whether this will be possible if i want to extract data from particular workbook to another workbook.
 
Back
Top