How to extract an URL from Excel cells with hyperlinks-Macro

I just wanted to convert some of my Excel cells to url values in my excel sheet which i got as the links while copy pasting them from internet. I tried writing my own macros and am not very good in that. After searching the internet for some time i got a very good macro that worked just fine.

Following the below steps will give you the step by step tutorial on how to create a macro and use this function.If you are already good in creating macros just go and get the code part alone.

Step by step How to Tutorial on How to extract URLs from Hyperlinnks in Excel using Macros:
1. First click on any area in excel and hit ALT+F11. You will be seen with a window as shown in the pic.



2. Now, Select insert and then Module from the drop down. You wil be ended up with a screen just like below.

3. Copy paste the below code as it is. Note: hypadd is your function in excel. you can view this under userdefined functions. If you want to assign another name just change the function name

 "Function hypadd(r As Range) As String
Dim s As String

If r.HasFormula Then
s = r.Formula
s_array = Split(s, Chr(34))
hyp = s_array(1)
Else
hyp = r.Hyperlinks(1).Address
End If
End Function
"



4. Now hit Alt+Q and go back to Excel. You will now close the window and come to the existing Spreadsheet.

5. Just save the workbook in macro enabled version of excel and enjoy the power of created macro.

1 comments:

Unknown said...

Hello I am a AS/400 Developer but want to move out from it.... will Cognos be a suitable choice for me... suggest ... I have work exp of 3 years so how much can i expect once i mdone with cognos training...suggest

Post a Comment