PDA

View Full Version : Solved: copy data from one worksheet to another in same workbook



shahcu
03-22-2007, 05:14 AM
Hi!

I would like to know how to copy data from one sheet to another using VBA code.

For example say :

I have entered data thru form in sheet1 that will get store in A, B and C columns.

Now say using VB form i have a command button(report) I need that when user click on button the entire data will get copied to sheet5 of same workbook in A,B and C columns.

Please help.
:think:

makako
03-22-2007, 05:49 AM
u could copy the page like this

Sheets("Sheets1").Copy Before:=Sheets(5)

or if you want to create these solumns just once and to copy data from time to time iy would probably be something like

Sheets("Sheets1").range("A1").currentregion.copy Sheets("Sheets5").range("A1").end(xldown)

(im not concidering you r using head titles

shahcu
03-22-2007, 06:00 AM
Hi!

Thanks for ur suggestion..

When i tried the same i got an error message "Run Time error 9" Subscript out of range...

I would also like you to know that I am using head titles in both the sheets ... Its a loan application form that I would like to copy from one sheet to another..

Pls help

lucas
03-22-2007, 06:06 AM
no need to copy...
Sub copytosheet5()
Sheets("Sheet5").Range("A2:C100").Value = Sheets("Sheet1").Range("A2:C100").Value
End Sub

shahcu
03-22-2007, 06:19 AM
Thanx a lot...

It works great..

Sorry to bother u again but in case if I only want to copy Column A and Column C only then what exactly i have to do...

Thanks a lot for all ur help...

lucas
03-22-2007, 06:23 AM
Sub copytosheet5()
Sheets("Sheet5").Range("A2:A100").Value = Sheets("Sheet1").Range("A2:A100").Value
Sheets("Sheet5").Range("C2:C100").Value = Sheets("Sheet1").Range("C2:C100").Value
End Sub

shahcu
03-22-2007, 10:10 PM
Thanx a lot..

It did the trick...

Regards,