|
-
Feb 16th, 2018, 06:00 AM
#25
Re: Import data from multiple html files into one excel worksheet
instead of using dir to get the filename you could try like
Code:
x = 1
fname = mypath & "file" & x & ".htm"
do until fname = ""
''''all your code for each file
x= x + 1
fname = mypath & "file" & x & ".htm"
loop
if any files are missing from the number sequence, it will stop at that point
Can we set the account column
set column to text, has to be done before the data is put in the cell
Code:
range("d1").entirecolumn.numberformat = "@"
change the D to whatever column you want
As mentioned in my earlier comment, for few page line items the data is not available in the date column so instead of keeping that cell blank it imports the next column data in the date column
as there are no columns at all in the html code, it is hard to change the way excel converts text to columns, possibly the easiest way would be, after import, to check where the last column is empty then insert the additional cell for those rows, but i am not sure how accurate that would be, and it would probably take quite some time to run, post some sample data of rows that do not have date and i will see if it is possible to fix the raw data, before importing, similar to the fix for internal
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
|