6
在以下子代碼中,我想限制它的作用(將超鏈接中的子字符串替換爲)到特定列。我寫了'*我的想法是快速修復。但我似乎無法找到一個很好的方式來獲取一個單元格的列值保存爲一個範圍變量。獲取範圍的列索引
Dim MyDoc As Worksheet
Dim MyCell As Range
...
For Each MyCell In MyDoc.UsedRange
If MyCell.Hyperlinks.Count > 0 Then
'* if mycell's columnnumber = 1 then
LinkURL = MyCell(1).Hyperlinks(1).Address
FindPos = InStr(1, LinkURL, FindString)
If FindPos > 0 Then 'If FindString is found
ReplaceLen = Len(FindString)
URLLen = Len(LinkURL)
PreStr = Mid(LinkURL, 1, FindPos - 1)
PostStr = Mid(LinkURL, FindPos + ReplaceLen, URLLen)
NewURL = PreStr & ReplaceString & PostStr
MyCell(1).Hyperlinks(1).Address = NewURL 'Change the URL
End If
'* End if
End If
Next MyCell
+ 1是的...祝賀上20K),表示這個問題 – 2012-08-09 12:11:36
正確的答案,但在具體情況下沒有幫助我。但我可能找到了另一種解決方法。 Thx的幫助:) – 2012-08-09 12:14:47
@SiddharthRout Yeaa謝謝!你並不遙遠;-) – assylias 2012-08-09 12:47:14