+ Reply to Thread
Results 1 to 18 of 18

Novice query- copying between sheets

Hybrid View

  1. #1
    Registered User
    Join Date
    07-16-2012
    Location
    Telford
    MS-Off Ver
    Excel 2003
    Posts
    14

    Novice query- copying between sheets

    Having scoured the forum I think everything I have come accross so far is a little more complicated than that which I want to achieve. I have a workbook with 10 identical sheets. The sheets are purely lists of info added row at a time. All I wish to do is have these rows copied to a separate "everything" sheet automatically, as and when the rows are filled. At present I have to cut and paste chunks at regular intervals. I don't need to do any filtering or anything, just a copy of each completed row on any other sheet to appear on the "everything" sheet. Is there an easy way?

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Novice query- copying between sheets

    Are the columns of data having the same headers in all your sheets?

    What is your data range? I mean what are the columns having the data? For e.g. A to K?
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    07-16-2012
    Location
    Telford
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Novice query- copying between sheets

    Yes, all columns have same headers, all sheets (including target sheet). Data is in columns C to H.

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Novice query- copying between sheets

    Do you want the copy paste to be triggered by a button?

    Its not ideal to have it run automatically, as it will be tough to identify which rows have been copied and which not.
    Instead, if you trigger it by a button, we can have the macro clean up the "everything" sheet and reload all the sheets' data into it.

    What do you say?

  5. #5
    Registered User
    Join Date
    07-16-2012
    Location
    Telford
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Novice query- copying between sheets

    I say a button on the 'everything' sheet would do just fine. Show me how!

  6. #6
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Novice query- copying between sheets

    Last question - do you need a column to state which sheet the data was copied from?

  7. #7
    Registered User
    Join Date
    07-16-2012
    Location
    Telford
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Novice query- copying between sheets

    Actually Arlette, that would be very useful indeed.

  8. #8
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Novice query- copying between sheets

    Oops another question - can you give me the headers that need to go into the "everything" sheet?

  9. #9
    Registered User
    Join Date
    07-16-2012
    Location
    Telford
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Novice query- copying between sheets

    Columns C-H are: Date,Description, Action,Operative,Hours,Complete.
    Thanks.

  10. #10
    Registered User
    Join Date
    07-16-2012
    Location
    Telford
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Novice query- copying between sheets

    I see you have posted some code for a similar thread Arlette:

    Option Explicit
    
    Sub create_format()
    Dim lrow As Long, i As Long, a As Long
    Dim fpath As String, xinput As String
    
    a = 1
    fpath = "D:\Test\"
    Workbooks.Open (fpath & "b.xls")
    xinput = InputBox("Please enter the value for x")
    With ThisWorkbook.Worksheets("Sheet1")
        lrow = .Range("A" & .Rows.Count).End(xlUp).Row
        For i = 1 To lrow
            If .Range("B" & i).Value = xinput Then
                Workbooks("b.xls").Worksheets("Sheet1").Range("A" & a).Value = .Range("A" & i).Value
                a = a + 1
            End If
        Next i
    End With
    
    End Sub
    Is this something like the approach I should be using?
    Last edited by arlu1201; 07-17-2012 at 05:58 AM. Reason: Use code tags in future.

  11. #11
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Novice query- copying between sheets

    No, this code is only to copy from one sheet to another sheet in a new workbook.

    I will give you the code shortly.

    Should the data be consolidated from column C onwards or should it start from A?

  12. #12
    Registered User
    Join Date
    07-16-2012
    Location
    Telford
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Novice query- copying between sheets

    Thanks for your help. The data starts in column C and ends in H. A & B are empty.

  13. #13
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Novice query- copying between sheets

    Try this code
    Option Explicit
    
    Sub cons_sheets()
    Dim ws As Worksheet
    Dim lrow As Long, lrow1 As Long
    
    Application.ScreenUpdating = False
    
    If Not Evaluate("ISREF(Summary!A1)") Then
        Worksheets.Add(after:=Worksheets(Worksheets.Count)).Name = "Summary"
    Else
        Worksheets("Summary").Cells.ClearContents
    End If
    Worksheets("Summary").Range("C1:I1") = Split("Date,Description, Action,Operative,Hours,Complete,Sheet", ",")
    
    For Each ws In ThisWorkbook.Worksheets
        If ws.Name <> "Summary" Then
            lrow = ws.Range("C" & Rows.Count).End(xlUp).Row
            ws.Range("C7:H" & lrow).Copy Worksheets("Summary").Range("C" & Rows.Count).End(xlUp).Offset(1, 0)
            lrow = Worksheets("Summary").Range("I" & Rows.Count).End(xlUp).Row
            lrow1 = Worksheets("Summary").Range("C" & Rows.Count).End(xlUp).Row
            Worksheets("Summary").Range("I" & lrow + 1 & ":I" & lrow1).Value = ws.Name
        End If
    Next ws
    
    Application.ScreenUpdating = True
    
    End Sub
    Copy the Excel VBA code
    Select the workbook in which you want to store the Excel VBA code
    Hold the Alt key, and press the F11 key, to open the Visual Basic Editor
    Choose Insert | Module
    Where the cursor is flashing, choose Edit | Paste

    To run the Excel VBA code:
    Choose Tools | Macro | Macros
    Select a macro in the list, and click the Run button
    Last edited by arlu1201; 07-17-2012 at 07:14 AM.

  14. #14
    Registered User
    Join Date
    07-16-2012
    Location
    Telford
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Novice query- copying between sheets

    This works brilliantly, thanks very much! I will try and learn something from the code for future reference.

    Just more two questions: a) Would it be difficult to get the data copy to start from from row7 onwards for each sheet? And b) Can I make it so it I click on a cell to activate the macro instead of going through the menus?

    Thanks again.

  15. #15
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Novice query- copying between sheets

    Am glad it worked.

    a. I have changed the code to start from row 7.

    b. You can insert a button on your sheet. Right click on it and say Assign macro and assign the macro cons_sheets. Thats it.

    To insert the button - Right click on your toolbar at the top of your screen and select the "Visual Basic" menu. You will find a command button there if you click on the control toolbox.

  16. #16
    Registered User
    Join Date
    07-16-2012
    Location
    Telford
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Novice query- copying between sheets

    Yep, works even better.

    I have managed to place a button but don't get the option to assign macro in design mode. Where am I going wrong?

  17. #17
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Novice query- copying between sheets

    If you click on the button, you will see some text appearing in the formula bar. Remove that text and then you should be able to see the assign macro on the right click.

  18. #18
    Registered User
    Join Date
    07-16-2012
    Location
    Telford
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Novice query- copying between sheets

    genuis! All sorted.
    Thanks Arlette

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1