A
A
Ambal892017-08-04 13:32:06
excel
Ambal89, 2017-08-04 13:32:06

How to add the same to links in excel?

Good afternoon, please tell me, there is a price list, which contains links to pictures of goods. Previously, the links worked as they are, but recently the hosting has changed the settings, and now you need to add an extension to all links, namely .jpg . Since there are a lot of goods, is it possible to do this in bulk somehow?
Links look like this:

spoiler
1fe1afb17de3497da0e6c826e08542af.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Fedoryan, 2017-08-04
@Ambal89

With a macro:

Sub AppendExt()
    Dim WB As Workbook
    Dim WS As Worksheet
    
    Dim Ri As Integer
    Dim Rj As Integer
    Dim Ci As Integer
    Dim Cj As Integer
    
    Set WB = Excel.ActiveWorkbook
    Set WS = WB.Worksheets("list1")
    
    ' Диапазон ячеек для замены

    ' Начальная строка
    Ri = 1
    ' Конечная строка
    Rj = 4
    ' Начальный столбец
    Ci = 1
    ' Конечный столбец
    Cj = 2
    
    For C = Ci To Cj
        For R = Ri To Rj
            If Not IsEmpty(WS.Cells(R, C)) Then
                WS.Cells(R, C).Value = WS.Cells(R, C).Value & ".jpg"
            End If
        Next R
    Next C
End Sub

Or just copy the necessary lines into any notepad with regular expression support and substitute everything that is missing at the end, and then replace the old links with this.
Sub AppendExt()
    Dim WB As Workbook
    Dim WS As Worksheet
    
    Set WB = Excel.ActiveWorkbook
    Set WS = WB.Worksheets("list1")
    
    For Each HL In WS.Hyperlinks
        HL.Address = HL.Address & ".jpg"
    Next
End Sub

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question