Create HTML and IFRAME Code

Use formulas in Excel to create HTML or IFRAME code, then add to a web page or blog post, to show links or embedded videos. Get the free workbook, to see how the formulas work.

HTML Code Template

The first sample file is designed to create product links, if you are an Amazon associate.

NOTE: The rules change occasionally, so check the current Amazon Associates agreement, to be sure that these links are in an acceptable format.

  • In the template, enter the product code and product title
    • NOTE: the Product code (ASIN) cell is formatted as text, to preserve any leading zeros
  • Enter your Amazon affiliate tracking ID, so the link will contain that ID
  • Then copy the link or the HTML code, and paste it into a web page or blog article.

build html for amazon link

Create a Simple URL Link

In the "Copy This Link" cell, a formula combines the first part of the Amazon URL, with the product code (ASIN) and the Tracking ID.

= & ProdCode & "?tag=" &TrackID

If you copy the code from cell B5, and paste into a blog post, you'll see a simple URL link, as shown below. The link works correctly, but doesn't show the product name.

Note: Debra Dalgleish is an Amazon Associate. As an Amazon Associate I earn from qualifying purchases.

Create a Product Name Link

In the "Copy This HTML" cell, a more sophisticated link is created. It shows the product name, and has a link to the product's URL.

The formula in that cell refers to the 4 HTML text cells, located below the Tracking ID cell.

build html for amazon link

The four HTML cells have snippets of text that are required for building the HTML code. The formula in cell B7 combines the product title and the link, with those four snippets of HTML code.

=HTML_01 & ProdTitle & HTML_02 & ProdLink
& HTML_03 & ProdTitle & HTML_04

All the cells are named, so it's easier to understand the formula. You can follow the colored references in the screen shot below.

build html for amazon link

If you copy the "Copy This HTML" cell, and paste into a web page, the link shows the product name. If you point to the link, the product title appears in a little popup. For example, here is the link created by the HTML code in the sample formula above

IFRAME Code Template

To embed a YouTube video, or other web content, on your website, you can use IFRAME code. In this template, there are 2 data entry sheets -- one for YouTube embed code, and one for other types of IFRAMES.

Fill in the details, such as the Video ID, and video name.

build iframe code

Combine the Code Strings

In a cell below the variable entry section, a formula creates the IFRAME code:

  • It uses the & operator, to combine text strings
  • The CHAR function uses 34 as its argument, to create double quote marks
  • The IF formulas return a variable based on Yes or No selections

iframe code

Use the IFRAME Code

To use the code, copy the IFRAME/HTML code, and paste it into a web page or blog article.

  • The iframe code shows the video
  • Below that, the HTML code shows a text link.

iframe code

Download the Sample Files

  • Amazon Links HTML: Click here -- -- to download the Amazon Links sample file. The zipped file is in xlsx format, and does not contain macros.
  • IFRAME Code: Click here -- -- to download the IFRAME code sample file. The zipped file is in xlsx format, and does not contain any macros.

More Tutorials

SUM Function



Count Functions




Hide VLOOKUP Errors

Last updated: April 16, 2021 11:34 AM