PDA

View Full Version : Solved: copy data in sheet1 and paste in sheet2



GohLS
05-23-2008, 09:47 AM
Hi Guys ,

i need help in some of the code.
currently i am working on a code and i am stuck. below is what i want to do.

copy from sheet 1 and paste in sheet 2
the data in sheet 1 header is fixed ( column A to F ) data to copy is Row 2 only and paste it in sheet 2 row 2. However with the same data in sheet1 ( nothing is change, row 2) , it will paste in sheet2 next row and so on ...

kindly help.

grichey
05-23-2008, 10:32 AM
are you trying to copy the entire sheet? I don't understand the object.

grichey
05-23-2008, 10:35 AM
Maybe this is what you're going for?

Sheets("Sheet1").Rows("2:2").Copy Destination:=Sheets("Sheet2").Range("A2")

GohLS
05-23-2008, 05:29 PM
sorry for my poor explaination.
what i am creating is a simple form.
where sheet1 will capture the data at sheet1 columnA row2 to columnF row2. after the data enter, with a click of a button.
it will paste to sheet2 starting from column A row2 to columnF row2.
this form is for a sample loan form where sheet1 will only use sheet1 columnA row2 to columnF only. where sheet 2 will keep on updating on next row if there is new entery. something like this.

i have created something but do not know how to post it up. so sorry.

please advise.

david000
05-23-2008, 07:03 PM
Sub test()
Dim Lastrow As Long
With Worksheets(1)
Lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
.Range("A1").Resize(Lastrow, 6).Copy
End With
Sheet2.Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial xlPasteValues
Application.CutCopyMode = False
End Sub

grichey
05-23-2008, 07:03 PM
This might work. I don't excel to test right now though.



sub hopefullynothomework()

dim counter as integer
counter = 2
Do
Sheets("Sheet1").Range("A" & counter &:F" & counter) _
.Copy Destination:=Sheets("Sheet2").Range("A" & counter)
Range("A"& counter).Select
counter = counter +1
Loop Until IsEmpty (selection)

end sub

grichey
05-23-2008, 07:04 PM
ha - nice timing David...

GohLS
05-24-2008, 07:39 PM
Thanks grichey & david
i modify a bit from david code cos i do not want to copy the header as well just data below the header.
here what i modify
Sub test()
Dim Lastrow As Long
With Worksheets(1)
Lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
.Range("A2").Resize(Lastrow, 6).Copy
End With
Sheet2.Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial xlPasteValues
Application.CutCopyMode = False
End Sub


as for grichey code

some error is there
Sub hopefullynothomework()

Dim counter As Integer
counter = 2
Do
Sheets("Sheet1").Range("A" & counter &:F" & counter) _
.Copy Destination:=Sheets("Sheet2").Range("A" & counter)
Range("A"& counter).Select
counter = counter +1
Loop Until IsEmpty (selection)

End Sub

error is highlighted as bold.
however u guys are great.

this is not a homework.
it a simple database for tracking my company sample that i am helping to do to track on the loan.

Thanks again