+ Reply to Thread
Results 1 to 8 of 8

copy the B column from all Sheets and dump the information in a "totals" sheet B column

Hybrid View

  1. #1
    Registered User
    Join Date
    03-27-2012
    Location
    Sofia
    MS-Off Ver
    Excel 2010
    Posts
    46

    copy the B column from all Sheets and dump the information in a "totals" sheet B column

    Hello guys,

    I have several sheets with tickets in the "B:B" ranges.
    I need to get all the info from the "B:B" ranges and copy it in one singe "B:B" column in my "total" sheet. (for example I have 10 tickets in Sheet 1, 20 tickets in Sheet 2, so I would have all 30 tickets in "B:B" in the "totals" sheet)
    Is it possible to do this with code instead of the IF command?

    I would appreciate any assistance and would like to thank you guys for all the help you are providing! (already assisted me twice today!!)

  2. #2
    Valued Forum Contributor
    Join Date
    02-09-2012
    Location
    Mauritius
    MS-Off Ver
    Excel 2007
    Posts
    1,055

    Re: copy the B column from all Sheets and dump the information in a "totals" sheet B colum

    Hi
    Yes it can be done. Pls post a sample data file
    Click *, if my suggestion helps you. Have a good day!!

  3. #3
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: copy the B column from all Sheets and dump the information in a "totals" sheet B colum

    Try...

    Make sure you have a sheet titled Total and also assumes you have a header row therefore starts at row 2.

    Sub movedata()
        Dim ws As Worksheet
        Dim LRsrc As Long
        Dim LRdst As Long
        For Each ws In ActiveWorkbook.Worksheets
            With ws
                If .Name <> "Total" Then
                    LRsrc = ws.Range("B" & Rows.Count).End(xlUp).Row
                    LRdst = Sheets("Total").Range("B" & Rows.Count).End(xlUp).Offset(1).Row
                    .Range("B2:B" & LRsrc).Copy Destination:=Sheets("Total").Range("B" & LRdst)
                End If
            End With
        Next ws
    End Sub
    HTH
    Regards, Jeff

  4. #4
    Registered User
    Join Date
    03-27-2012
    Location
    Sofia
    MS-Off Ver
    Excel 2010
    Posts
    46

    Re: copy the B column from all Sheets and dump the information in a "totals" sheet B colum

    Jeff,
    Thank you very much, this works great, it even keeps the formatting, which is actually the cherry on top !!!
    I appreciate it very very much!!

    Just one little detail - for some reason I got some additional cells - Scenario Summary, Changing Cells: and Result cells: and then - "Notes: Current Values column represents values of changing cells at time Scenario Summary Report was created. Changing cells for each scenario are highlighted in gray."
    Would it be possible to not get this?
    Thanks in advance again!

  5. #5
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: copy the B column from all Sheets and dump the information in a "totals" sheet B colum

    This is not clear to me. Can you post a sample mocked up workbook to ensure we get the best solution? A before and after example helps tremendously

  6. #6
    Registered User
    Join Date
    03-27-2012
    Location
    Sofia
    MS-Off Ver
    Excel 2010
    Posts
    46

    Re: copy the B column from all Sheets and dump the information in a "totals" sheet B colum

    This is weird, because I tried to reproduce the scenario in another file, but it works perfectly there.
    Anyway, I will try to figure out what's happening in my sheet, since i have a bunch of other macros running, but basically this is a screenshot with the result from my particular file:
    123.jpg

    One last thing, do you think there is a way around the "Total" name, since one of my very important scripts is to have the number of cells, that have certain information, being displayed in the Sheet's name, so for example - the first time the sheet is named Total, but after I run the macro, if I have a total of 123 tickets, it will get renamed to "Total(123)"?
    Thanks in advance for the assistance, I appreciate it very much!
    Last edited by AlienPump; 04-24-2012 at 03:25 AM.

  7. #7
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: copy the B column from all Sheets and dump the information in a "totals" sheet B colum

    Yes this is possible, but I'm headed out the door right now for work but can get back to this in about an hour. Hope that will work for you!

  8. #8
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: copy the B column from all Sheets and dump the information in a "totals" sheet B colum

    Not sure where you are getting your tickets from, but after the macro runs, the sheet will be renamed with the value in Range("Al").

    Example: If you have 123 in Range("A1") then you would end up with >> Total (123)

    S
    ub MoveData()
        Dim ws As Worksheet
        Dim LRsrc As Long
        Dim LRdst As Long
        Const StartRow As Long = 2
        Const ColLet As String = "B"
        For Each ws In ActiveWorkbook.Worksheets
            With ws
                If .Name <> "Total" Then
                    LRsrc = ws.Range(ColLet & Rows.Count).End(xlUp).Row
                    LRdst = Sheets("Total").Range(ColLet & Rows.Count).End(xlUp).Offset(1).Row
                    .Range(.Cells(StartRow, ColLet), .Cells(LRsrc, ColLet)).Copy Sheets("Total").Range("B" & LRdst)
                End If
            End With
        Next ws
        Application.Goto Sheets("Total").Range("A1")
        With Sheets("Total")
            .Name = "Total (" & .Range("A1") & ")"
        End With
    End Sub

+ 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