How Do I Add/Remove links with VBA?

I want to remove all the hyperlinks in my spreadsheet

That’s super easy – just right click on the column with the hyperlinks and click “Remove Hyperlinks”.

A problem arises when you want to add them quickly back in, as there is, unfortunately, no option of doing so, other than right-clicking on a link after link, which could be quite the snail-paced exercise.

What you could do quickly, however, is make use of the VBA code below.

As the VBA snippet evaluates the content of a cell, there are a couple of if-then-scenarios that pre-determine what’s executed:

  1. If a cell already has a hyperlink, that hyperlink is deleted
  2. If a cell has no hyperlink, a hyperlink is added. Depending on the content of the cell, that could be a link to a website or a link to an e-mail address

Happy VBA coding!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.