Vba Problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi
I have a macro that does almost what i want, but it misses me some detail.
The objective is to copy to other sheet some data, but this formula makes
two things i cant control, it duplies information if i click 2 times macro
button, and it goes to First row in the sheet i want.
I would like to control this 2 elements. How can i?
Thanks

Sub Ferias2()
For i = 7 To Cells(Rows.Count, "A").End(xlUp).Row
If Cells(i, "A").Value = "1" Then
With Worksheets("1")
nextrow = .Cells(.Rows.Count, "A").End(xlUp).Row + 1
End With
Cells(i, "C").Resize(, 36).Copy Worksheets("1").Range("A" &
nextrow)

End If
next i

End Sub
 
Why not just copy/paste the data once?...

Sub Ferias3()
Dim i As Long
Dim nextrow As Long

i = Cells(Rows.Count, 1).End(xlUp).Row
With Worksheets("1")
nextrow = .Cells(.Rows.Count, 1).End(xlUp).Row + 1
End With
Range("C7", Cells(i, 3)).Resize(, 36).Copy Worksheets("1").Cells(nextrow, 1)

End Sub
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"Micos3" <[email protected]>
wrote in message
Hi
I have a macro that does almost what i want, but it misses me some detail.
The objective is to copy to other sheet some data, but this formula makes
two things i cant control, it duplies information if i click 2 times macro
button, and it goes to First row in the sheet i want.
I would like to control this 2 elements. How can i?
Thanks

Sub Ferias2()
For i = 7 To Cells(Rows.Count, "A").End(xlUp).Row
If Cells(i, "A").Value = "1" Then
With Worksheets("1")
nextrow = .Cells(.Rows.Count, "A").End(xlUp).Row + 1
End With
Cells(i, "C").Resize(, 36).Copy Worksheets("1").Range("A" & nextrow)

End If
next i
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top