I have a column in excel with unformatted image links. I've highlighted the image links in the raw data below
I need an excel VBA macro to convert data like so:
I wrote a regular expression http[s?]:\/\/.*(.png|.jpg)
to pattern match the links. Sample:
I modified the function found here to do the processing
Function ExtractURL(ByVal text As String) As String
Dim result As String
Dim allMatches As Object
Dim RE As Object
Set RE = CreateObject("vbscript.regexp")
RE.Pattern = "(http[s?]:\/\/.*(.png|.jpg))"
RE.Global = True
RE.IgnoreCase = True
Set allMatches = RE.Execute(text)
If allMatches.Count <> 0 Then
result = allMatches.Item(0).submatches.Item(0)
End If
ExtractURL = result
End Function
How do I apply this function to replace the values in Column A?
EDIT: CLARIFICATION/CONTEXT
I have 1000+ image links. I simply showed 5 images to make the example straightforward. It needs to work only off of column A, since its part of a larger series of macros.