Results 1 to 31 of 31

Importing Excel Files & Copying Data Horizontally (instead of vertically) Help!

Threaded View

  1. #1
    Registered User
    Join Date
    01-20-2014
    Location
    Fort Lauderdale, FL
    MS-Off Ver
    Microsoft Office 2013
    Posts
    16

    Importing Excel Files & Copying Data Horizontally (instead of vertically) Help!

    Hello,

    I've been lurking for a while and have found this site extremely useful. I'm trying to change a macro I used on another project. It imports the 300+ excel files I have stored in a folder into a single spreadsheet. The only problem I'm having is getting it to compile the data horizontally (not transposed, but copied and pasted "as-is" in new columns instead of rows).
    Can someone please help me with this? Here is the code as it currently stands (vertical):

    Sub Consolidate()
    Dim sh As Worksheet, lr As Long, fPath As String, wb As Workbook, sh2 As Worksheet, fNm As String
    Dim lstRw As Long, rng As Range
    Set sh = Sheets(1) 'Edit name of master sheet
    fPath = "C:\temp" 'Edit directory path
    If Right(fPath, 1) <> "\" Then
    fPath = fPath & "\"
    End If
    fNm = Dir(fPath & "*.xl*")
    Do
    lr = sh.Cells(Rows.Count, 1).End(xlUp).Row 'Assumes Col A will be posting reference
    Set wb = Workbooks.Open(fPath & fNm)
    Set sh2 = wb.Sheets(1)
    lstRw = sh2.Cells(Rows.Count, 1).End(xlUp).Row
    Set rng = sh2.Range("A2:A" & lstRw)
    rng.EntireRow.Copy sh.Range("A" & lr + 1)
    wb.Close False
    fNm = Dir
    Loop While fNm <> ""
    End Sub
    Last edited by WinNuke95; 01-20-2014 at 07:40 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 5
    Last Post: 01-27-2013, 09:36 PM
  2. Replies: 9
    Last Post: 10-11-2012, 07:50 AM
  3. Excel 2007 : Merging data horizontally vs. vertically
    By enhydra in forum Excel General
    Replies: 4
    Last Post: 12-12-2010, 06:16 PM
  4. when importing .txt files can I separate the data horizontally
    By Chrisinct in forum Excel - New Users/Basics
    Replies: 5
    Last Post: 07-07-2006, 02:15 PM
  5. A tough one! line up vertically/horizontally through data
    By djvice in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-14-2005, 04:32 PM

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