我从来没有做过一些宏,而且我已经制作了一个vb宏。 如果" B"找到了单元格,如果是,我可以用侧栏中的匹配值替换该值。
由于我从未这样做,我不知道如何开始。 有人已经做过类似的事吗?
答案 0 :(得分:0)
This是从哪里开始的。
这足以让你朝着正确的方向前进。
答案 1 :(得分:0)
我做了一个似乎有效的宏,但它并没有取代链接的价值
Sub ReplaceLink()
Dim searchedString As String, replaceString As String
Dim hLink As Hyperlink
'loop shhet
For Each sh In ActiveWorkbook.Worksheets
For Each hLink In sh.Hyperlinks
'searched address
searchedString = Replace(hLink.Address, " ", "%20")
'new url
replaceString = NewUrl(searchedString)
'Search for the specified text
If Not IsEmpty(replaceString) Then
hLink.Address = Replace(hLink.Address, hLink.Address, replaceString)
Else
hLink.Range.Interior.ColorIndex = 3
End If
Next hLink
Next sh
End Sub
函数NewUrl(searchingString As String)As String Dim MyPath $,MyWB $ Dim GCell As Range
MyPath = "C:\temp\"
'The name of the workbook in which to search.
MyWB = "migration_link.xls"
Workbooks.Open Filename:=MyPath & MyWB
'Set GCell = ActiveSheet.Cells.Find(searchedString)
Set GCell = ActiveSheet.Cells.Find(searchedString)
'if a matching is found, set new url
If Not GCell Is Nothing Then
NewUrl = ActiveSheet.Range("C" & GCell.Row)
Else
NewUrl = ""
End If
结束功能