Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50061

Loop macro to grab all data (Row 15 down) from multiple tabs and paste in Reports tab

$
0
0
Hi All,

Hoping you can help with a data mining code for a spread sheet I have that holds many tabbed sheets, each that have a standard format that includes the first 15 rows as a header and row data from row 15 down to 200 max rows. Each row has data in columns from A to Y but rarely all 200 rows, often only 50. (ie total copy range could be as many as A15:Y200 but likely less)

I'm looking to create a reports sheet which:

A. Copy's values from each each sheet A15:Y200
B. Pastes values into Reports tab (Sheet 24)

I had a similar type of code that did this but only took singular cell values from each work sheet and made a list of them. In this case I'd like to do more in pasting all the values from row 15 and below so they're all in the same sheet. I attempted to edit it (as below) without luck, i'm not tied to that code style though!

Any advice? Thanks in advance!


Code:

   
Private Sub CommandButton1_Click()
    Dim ws As Worksheet 'Define WS as worksheet
    Application.ScreenUpdating = False 'don't update the screen (reduces lag time)
   
   
    Sheet24.Activate 'select report tab and clear row contents (necesairy to allow macro to update data and run properly)
    Range("A15:BZ65536").Select
    Selection.Delete Shift:=xlUp
   
 
    For Each ws In Worksheets 'for each worksheet (WS), take the specified range and paste special (values only)
        If ws.Name <> "Budget Summary" And ws.Name <> "Remaining" And ws.Name <> "Reports" Then
            'if the named sheet is not Dashboard, Template or Market, then run the if statement to grab data
           
            'Account Profile and Contract Status
           
            ws.Range("A15:Y200").Copy r  'used to take singular cell value and paste special, tried to include a range but doesnt work
            ActiveSheet.Range("A65536").End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
           
                   
        End If 'end  data grab, continue to next sheet (aka next tab)
    Next ws 'end worksheet (WS) loop
   
 
   
    Application.ScreenUpdating = True 'display results
    ActiveWindow.ScrollColumn = 1
    ActiveWindow.ScrollRow = 1

End Sub


Viewing all articles
Browse latest Browse all 50061

Trending Articles