Results 1 to 14 of 14

Thread: [RESOLVED] Copy in excel

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2005
    Location
    Puerto Rico
    Posts
    134

    Resolved [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!!
    ed!th

  2. #2
    Addicted Member
    Join Date
    Jan 2006
    Location
    Montreal, Canada
    Posts
    152

    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:
    1. Sheets("SheetName").Select
    2. Sheets("SheetName").Copy Before:=Sheets(2)

  3. #3
    Fanatic Member VBAhack's Avatar
    Join Date
    Dec 2004
    Location
    Sector 000
    Posts
    617

    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.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jul 2005
    Location
    Puerto Rico
    Posts
    134

    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 :-)
    ed!th

  5. #5
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    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:
    1. Range("C8").Select
    2.     Selection.Copy
    3.     Range("E11").Select
    4.     ActiveSheet.Paste

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jul 2005
    Location
    Puerto Rico
    Posts
    134

    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!!!
    ed!th

  7. #7
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    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:
    1. Private Sub Move_click()
    2.  
    3. Dim iCol as Integer
    4. Dim i as Integer
    5.  
    6. For iCol = 1 To 14
    7.   i = 1
    8.   Do Until Sheet5.Cells(i, iCol).Value = ""
    9.     Sheet4.Cells(i, iCol).Value = Sheet5.Cells(i, iCol).Value = ""
    10.     i = i + 1
    11.   Loop
    12. Next iCol
    13.  
    14. End Sub

    If you want to copy the entire used range of cells, it would be better to do this instead:
    VB Code:
    1. Private Sub Move_click()
    2.  
    3.  Sheet5.UsedRange.Copy Sheet4.Cells(1, 1)
    4.  
    5. End Sub

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Jul 2005
    Location
    Puerto Rico
    Posts
    134

    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 :-)
    ed!th

  9. #9
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Copy in excel

    it didnt work
    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:
    1. 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.

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Jul 2005
    Location
    Puerto Rico
    Posts
    134

    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.
    ed!th

  11. #11

    Thread Starter
    Addicted Member
    Join Date
    Jul 2005
    Location
    Puerto Rico
    Posts
    134

    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 :-)
    ed!th

  12. #12
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    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:
    VB Code:
    1. For iCol = 1 To 11
    2.   i = 7

  13. #13

    Thread Starter
    Addicted Member
    Join Date
    Jul 2005
    Location
    Puerto Rico
    Posts
    134

    Re: [RESOLVED] Copy in excel

    thanks for the help!!! I have a question about Ms Access, can u help? Do u know about Access?
    ed!th

  14. #14
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    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
  •  



Click Here to Expand Forum to Full Width