Extracting a URL from hyperlinked text in Excel cell

前端 未结 8 2230
孤街浪徒
孤街浪徒 2020-12-17 23:43

I have a table full of Hyperlinked text in excel, so it\'s basically a bunch of names but when I click on one, it takes me to some URL in my default browser.

So I am

相关标签:
8条回答
  • 2020-12-18 00:14

    I just ran into this issue and this is what worked for me:

    I used the FormulaR1C1 extension method for a range. So my code looked like this:

                        for (int r = 2; r <= sheetRange.Rows.Count; r++)
                        {
                            documentRecord = new List<string>();
                            for (int c = 1; c <= wkCol; c++)
                            {
                                documentRecord.Add(sheetRange.Cells[r, c].FormulaR1C1); 
                            }
                            AllRecords.Add(documentRecord);
                        }
    

    When the record is added to the list of records, the value of whatever the cell range was is formatted into a clickable-hyperlink.

    0 讨论(0)
  • 2020-12-18 00:15

    You can use VBA code to achieve this. Press Alt + F11 to open VB editor, Insert a Module and paste the code below:

    Sub run()    
        On Error Resume Next    
    
        For Each hLink In Selection    
            Range(hLink.Address).Offset(0, 1) = hLink.Hyperlinks(1).Address    
        Next    
    End Sub
    

    Save your excel file[in excel 2007 and above save as macro enabled...]

    0 讨论(0)
提交回复
热议问题