Macro for creating basic HTML table? (from selected data)

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Hermanito

Well-known Member
Joined
Apr 4, 2007
Messages
1,238
I wrote one for my own use... it recognises the following things:
- background color
- horizontal text alignment
- merged cells (vertical and horizontal)
- bold, italic, underlined

It only generates the text with the table tags included, not a complete html document, and outputs this to the Immediate window, nothing fancy, but it works fine for what I need...
If you have enough with these features, let me know, I'll post the code...
 

Matt Rhoades

New Member
Joined
Aug 27, 2009
Messages
3
thats more than enough i think.

I really just want to get the table with the padded grid lines so I can steal it and spruce it up elsewhere!

Thanks, can I get that code?
 

Trevor G

Well-known Member
Joined
Jul 17, 2008
Messages
6,707
Office Version
  1. 2016
Platform
  1. Windows
If you select to record a macro and then use the office button you can look at the option to use save as other formats and then select the html from there. the code will look like this:

ActiveWorkbook.SaveAs Filename:="C:\Users\Trevor G\Documents\test.htm" _
, FileFormat:=xlHtml, ReadOnlyRecommended:=False, CreateBackup:=False

You will have a little extra to do, like changing activeworkbook to activesheet
 

Hermanito

Well-known Member
Joined
Apr 4, 2007
Messages
1,238
Okay.... here it is... you will need to put all this code in a module. Also, make sure that the workbook you put this in, has a reference to the Microsoft Forms 2.0 Object Library. This is needed for the functionality to put the generated table in the clipboard.
Usage: select a rectangular range, run macro, choose ConvertSelection, paste result wherever you need it...

PM me an email-address and I will send the workbook to you...
 
Last edited:

Forum statistics

Threads
1,136,331
Messages
5,675,156
Members
419,552
Latest member
jsanjur

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top