|
-
Jan 9th, 2006, 01:00 PM
#1
Thread Starter
Addicted Member
[RESOLVED] Copy in excel
Hi
I need help on how to copy the information I have in one spread sheet to another spread sheet?????
Is this possible? Who can help or where can i find information on how to do this?
Thanks for any help!!
-
Jan 9th, 2006, 01:12 PM
#2
Addicted Member
Re: Copy in excel
We need a little more info...
same workbook?
you want to copy the whole sheet or only its data??
if you want to copie the whole sheet in the same workbook here is the code
VB Code:
Sheets("SheetName").Select
Sheets("SheetName").Copy Before:=Sheets(2)
-
Jan 9th, 2006, 02:50 PM
#3
Fanatic Member
Re: Copy in excel
The best thing to do in a situation like this is to turn on the macro recorder, manually step through what you want to do, and use the generated code as a starting point.
-
Jan 9th, 2006, 03:09 PM
#4
Thread Starter
Addicted Member
Re: Copy in excel
Hi,
Yes i want to copie only it's data. But there'r a "small" problem;
I don't know the steps to create a macro or Vb code.
So, I'll also need help on how to find the instruction to create the vb code and the macro.
thanks for the quick reply :-)
-
Jan 9th, 2006, 04:15 PM
#5
Re: Copy in excel
To create a macro, open up the main Excel window and go to "Tools" - "Macros" - "Record new macro..".
Then perform the tasks manually, and click on the "stop" button - the code for your actions will now be written to a module in the VBA editor.
For copying a cell it will probably look like this:
VB Code:
Range("C8").Select
Selection.Copy
Range("E11").Select
ActiveSheet.Paste
-
Jan 11th, 2006, 02:26 PM
#6
Thread Starter
Addicted Member
Re: Copy in excel
hi,
thanks for the help, but its not working. I can get it to pass or paste the data to the next sheet.
I do have the button and this is the code:
Option Explicit
Dim a As String
Dim i As Integer
'Private Sub CommandButton1_Click()
' UserForm1.Show
'End Sub
Private Sub Move_click()
i = 1
a = "A"
Call rutina
a = "B"
Call rutina
a = "C"
Call rutina
a = "D"
Call rutina
a = "F"
Call rutina
a = "G"
Call rutina
a = "H"
Call rutina
a = "I"
Call rutina
a = "J"
Call rutina
a = "K"
Call rutina
a = "L"
Call rutina
a = "M"
Call rutina
a = "N"
Call rutina
End Sub
Sub rutina()
Do Until Sheet5.Range(a & i).Value = ""
Sheet4.Range(a & i).Value = Sheet5.Range(a & i).Value = ""
i = i + 1
Loop
i = 1
End Sub
But nothing is happening, i know that it's all worng....please what ever input will be appreciated!!!
-
Jan 11th, 2006, 03:00 PM
#7
Re: Copy in excel
That should copy some data, but be careful about what Sheet4 and Sheet5 are (the names on tabs aren't nescesarily the same as the object names) .
Your code isn't the ideal way of doing what you did - it could be put into 2 nested loops, just using Cells instead of Range, ie:
VB Code:
Private Sub Move_click()
Dim iCol as Integer
Dim i as Integer
For iCol = 1 To 14
i = 1
Do Until Sheet5.Cells(i, iCol).Value = ""
Sheet4.Cells(i, iCol).Value = Sheet5.Cells(i, iCol).Value = ""
i = i + 1
Loop
Next iCol
End Sub
If you want to copy the entire used range of cells, it would be better to do this instead:
VB Code:
Private Sub Move_click()
Sheet5.UsedRange.Copy Sheet4.Cells(1, 1)
End Sub
-
Jan 12th, 2006, 10:56 AM
#8
Thread Starter
Addicted Member
Re: Copy in excel
hello
I was going to tell you about the entire used range of cells, i don't really need to copy all of it. For example: i want to start at A7 - K7 and paste or move everything within that range to the new sheet also starting at A7 - K7.
I used the code u gave me above and it didnt work, this is how i copied.:::
Option Explicit
Dim a As String
Dim i As Integer
Private Sub movebutton_Click()
Dim iCol As Integer
Dim i As Integer
For iCol = 1 To 14
i = 1
Do Until Sheet3.Cells(i & iCol).Value = ""
Sheet2.Cells(i, iCol).Value = Sheet3.Cells(i, iCol).Value = ""
i = i + 1
Loop
Next iCol
End Sub
Thanks again for your help :-)
-
Jan 12th, 2006, 01:33 PM
#9
Re: Copy in excel
What happened? In order for me to help, you need to give much more specific info.
If you only want the values A7 to K7, you can use this:
VB Code:
Sheet2.Range("A7:K7").Copy Sheet3.Range("A7:K7")
Otherwise you can modify the code above, set the numbers in the "For iCol" line to the first and last column (A=1, B=2, etc), and change "i = 1" to the row to start from.
-
Jan 12th, 2006, 01:59 PM
#10
Thread Starter
Addicted Member
Re: Copy in excel
Ok, it's "kind of working". but Its deleting whatever data I have in those lines and it's not sending them to the sheet2 ....??? the sheet it's still blank.
-
Jan 12th, 2006, 02:03 PM
#11
Thread Starter
Addicted Member
Re: Copy in excel
I need to load the data from one sheet to another without deleting the data.
Both sheets are suppose to have the same data or info.
I have a header or the logo at the top of each sheet, so i dont want to move the first 5 or 6 lines. But the rest of the cells from A7 - K7 to A55 - K55 (for example)
are the ones I need to move to the other sheet.
I hope u can understand me, if u need more info please ask!!!
thanks :-)
-
Jan 12th, 2006, 08:11 PM
#12
Re: Copy in excel
As it is "deleting" data, I can only assume that you have got the sheets the wrong way around.
Apart from that, these should be the only changes you need:
-
Jan 13th, 2006, 09:55 PM
#13
Thread Starter
Addicted Member
Re: [RESOLVED] Copy in excel
thanks for the help!!! I have a question about Ms Access, can u help? Do u know about Access?
-
Jan 13th, 2006, 10:21 PM
#14
Re: [RESOLVED] Copy in excel
I know some things about Access, and may be able to answer. It would be best to start a new thread in this forum, rather than continue in this thread.
I'll have a look, and I'm sure others will too.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|