Results 1 to 12 of 12

Open text file and store specific columns using arrays

Threaded View

  1. #1
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Open text file and store specific columns using arrays

    Hello everyone
    I have Sample text file (in fact I would deal with large number of text files ) >>
    Manually I copy the text file data and put it into sheet then select column A (Where I put this data) >> go to Data tab >> Click "Text to Columns" and split data by comma
    Then delete the first four columns and the header row...
    There are four columns remaining //


    After that I am using this code to have these results in specific way
    Sub Test()
        Dim arr     As Variant
        Dim p       As Long
        Dim w       As Long
        Dim x       As Long
        
        arr = Sheets("Sheet1").Range("A1:E75").Value
        ReDim temp(1 To UBound(arr, 1) * UBound(arr, 2), 1 To 2)
        x = 1
        
        For p = 1 To 365
            temp(p, 1) = p
        Next p
        
        For p = LBound(arr, 1) To UBound(arr, 1)
            For w = LBound(arr, 2) To UBound(arr, 2)
                temp(x, 2) = arr(p, w)
                x = x + 1
            Next w
        Next p
        
        Sheets("Sheet1").Range("J1").Resize(UBound(temp, 1), UBound(temp, 2)).Value = temp
    End Sub

    ** I need not to deal with the excel file when manipulating data .. I just need to deal directly with the text file and do all these tasks using arrays
    Mr. Karedog has helped me in similar issue .. but this is different a little

    Thanks advanced for help
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by YasserKhalil; 03-22-2017 at 04:44 PM.
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Open CSV file using vba excel without change text to columns automatic
    By alcalina in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 09-04-2024, 07:55 AM
  2. [SOLVED] Big Excel Data File ( 3 Deep columns ) To Text File To 3 Big VBA 1 Dimensional Arrays
    By Doc.AElstein in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-08-2017, 10:47 AM
  3. [SOLVED] Open text file and copy specific rows into spreadsheet column
    By larsahl in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-17-2014, 07:02 AM
  4. Open other excel files with specific text in the file name
    By Kramxel in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-10-2013, 04:45 AM
  5. VBA to open .CSV file and format Columns A and C as text
    By maacmaac in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-12-2012, 12:56 PM
  6. Perform macro "on open" specific file- store macro in Personal Macro Workbook?
    By thompssc in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-17-2012, 12:38 PM
  7. Open text file to specific workbook
    By WasWodge in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-22-2011, 05:44 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