Reply to topic  [ 5 posts ] 
load html files into excel in seperate tabs 
Author Message
Has a life
User avatar

Joined: Sun May 17, 2009 12:21 pm
Posts: 93
Location: Newport, Shropshire
Reply with quote
Hi all,
I have a requirement to load a number of html files in numerical order in to excel to be able to then graph data from them,
Does anyone know of a way to do this. I have googled and found a macro that does part of the job but the files are loaded in a random order, I need them in a specific order.

regards

Alan

_________________
Image

Image Image


Thu Feb 23, 2017 7:44 pm
Profile
Doesn't have much of a life

Joined: Sat Apr 25, 2009 6:50 am
Posts: 1911
Reply with quote
I've no needed to myself, but I have seen other people automate Excel rather heavily through PowerShell. And now you mention it, I probably owe somebody at work a script to do something pretty similar.
The basics of powersehelling Excel are covered here and many other places.

You should be able to write up something that will collect all the contents of some particular folder which match *.html, then sort them by name or date created or whatever, then pipe that collection into a function that loop through in the order they are given to add a sheet with that content to a new workbook, and finally save it out. With better Excel Fu, you might jimmy it to make the graph for you.

If I write my thing, I'll have half of what you need, making it import html files shouldn't be a big leap.
But the nice chaps at these subreddits will probably sort you out more quickly.
https://www.reddit.com/r/PowerShell/
https://www.reddit.com/r/usefulscripts/


Thu Feb 23, 2017 10:12 pm
Profile
What's a life?
User avatar

Joined: Thu Apr 23, 2009 8:25 pm
Posts: 10691
Location: Bramsche
Reply with quote
VBA would be the easiest bet, if we are talking about a large number of files.

If it is only a few, you can open them individually and then right click on the sheet name at the bottom and "move or copy" it to you main file. It will then be copied over to the new file et voila!

That would be simpler / quicker with have a dozen to a dozen files, if you are talking about several dozen, then a VBA macro is probably your best bet.

_________________
"Do you know what this is? Hmm? No, I can see you do not. You have that vacant look in your eyes, which says hold my head to your ear, you will hear the sea!" - Londo Molari

Executive Producer No Agenda Show 246


Fri Feb 24, 2017 6:03 am
Profile ICQ
What's a life?
User avatar

Joined: Thu Apr 23, 2009 7:26 pm
Posts: 17040
Reply with quote
Depending on exactly how much of the files you need to get rid of to just get to the data you need, you could probably actually do it with windows powershell

get-content *.htm* | (maybe select -string to 'grep' for just the lines of data you need) | export-excel somefilename.xlsx

powershell is actually quite good at reading/writing files in standard formats like CSV, HTML etc.


Fri Feb 24, 2017 11:13 am
Profile
Has a life
User avatar

Joined: Sun May 17, 2009 12:21 pm
Posts: 93
Location: Newport, Shropshire
Reply with quote
Thanks for the answers. Yes it is a subset of the files I actually need s maybe a course in powershell to pick out the parts would be best.

thanks again.

regards

Alan

_________________
Image

Image Image


Fri Feb 24, 2017 2:48 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software.