-
Mar 10th, 2020, 03:47 PM
#1
Thread Starter
New Member
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!
-
Mar 10th, 2020, 04:13 PM
#2
Re: Extract text from only second row from all excel files in folder.(this row is mer
-
Mar 11th, 2020, 05:31 AM
#3
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|