Results 1 to 3 of 3

Thread: Extract text from only second row from all excel files in folder.(this row is merged)

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2020
    Posts
    11

    Post Extract text from only second row from all excel files in folder.(this row is merged)

    I want to,

    Extract text from only second row of all excel files in folder along with file name and update in a new file, with the text and file name.
    (PS: the row is merged column cells)

    Appreciate any help. Thanks!

  2. #2
    PowerPoster jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    2,393

    Re: Extract text from only second row from all excel files in folder.(this row is mer


  3. #3
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Extract text from only second row from all excel files in folder.(this row is mer

    the row is merged column cells)
    one sheet or multiple sheets to each workbook?


    here is an example for processing all the files in a folder, it only looks at the first worksheet, it also does not look at the merged cells, but that is not hard to add in
    Code:
    set xl = createobject("excel.application")
    pth = "C:\mypath\"    '   change to suit
    fname = dir(pth & "*.xls")   ' find first xls file in folder
    do while len(fname) > 0
        set xl.wb = workbooks.open(pth & fname)
        s = Join(WorksheetFunction.Transpose(WorksheetFunction.Transpose(Range("a2").Resize(, 5))), "\")   '  change the resize and separator to suit
        debug.print s
        wb.close false   ' do not save changes
        fname = dir  '   get next file
    loop
    xl.quit
    set xl = nothing
    this was typed directly into the browser, so may contain typos or code errors
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width