+ Reply to Thread
Results 1 to 2 of 2

Stacking Files VBA

  1. #1
    Registered User
    Join Date
    08-22-2019
    Location
    NY
    MS-Off Ver
    2010
    Posts
    4

    Stacking Files VBA

    Hello, new to VBA and coding in general.
    I am trying to stack a group of reports into a consolidated file. Not sure why the 2nd report is not pasting under the 1st report.
    Instead, it is overriding the data from the 1st report.
    I assume the issue relates to Dim/Set? Still trying to understand how that works.
    Any feedback would be greatly appreciated.

    Thanks!

    -------

    Sub Report_Stack()
    Dim wb As Workbook
    Set wb = Workbooks.Add
    With wb
    .Title = "Reports Stacked"
    .SaveAs Filename:="Reports Stacked"
    End With
    Workbooks.Open ("Z:\Report-1.xlsx")
    Windows("Report-1.xlsx").Activate
    Cells.Copy
    Windows("Reports Stacked.xlsx").Activate
    Range("A1").Select
    Cells.PasteSpecial
    Selection.End(xlDown).Select
    ActiveCell.Offset(1).Select
    Workbooks.Open ("Z:\Report-2.xlsx")
    Windows("Report-2.xlsx").Activate
    Cells.Copy
    Windows("Reports Stacked.xlsx").Activate
    Cells.PasteSpecial
    Selection.End(xlDown).Select
    ActiveCell.Offset(1).Select
    End Sub
    Last edited by sm26mz; 08-19-2020 at 02:15 PM.

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,274

    Re: Stacking Files VBA

    End down is not reliable, since it depends on the structure of the data - you could end up at the bottom of the worksheet, or you could end up one row down.

    Here is how I would do it:

    Please Login or Register  to view this content.
    Bernie Deitrick
    Excel MVP 2000-2010

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Stacking Files in a Folder
    By sahm2 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-23-2019, 12:55 PM
  2. Replies: 8
    Last Post: 12-24-2018, 07:14 AM
  3. Help with column stacking
    By mspi18 in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 05-14-2013, 05:54 PM
  4. Stacking many columns into one
    By pickslides in forum Excel General
    Replies: 2
    Last Post: 01-08-2012, 08:04 PM
  5. Stacking a bar graph??
    By mike_hill2107 in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 06-26-2008, 04:34 AM
  6. Stacking 2 bars into one
    By musicgirl in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 07-20-2005, 08:05 PM
  7. stacking in cells
    By froggy2472 in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 04-13-2005, 09:06 PM

Tags for this Thread

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