我在寻找解决方案的论坛上搜寻过。
我有一个代码,用于根据列B单元格值创建超链接。它可以工作,但只有在我选择单元格的时候运行sub。
如果H列值中的单元格为“ok”,我需要的是自动添加超链接
Sub Hyperlinks()
Dim r As Range
Dim FilePath As String
If Intersect(Columns("B"), Selection) Is Nothing Then Exit Sub
For Each r In Intersect(Selection, Range("B2:B" & _
Cells(Rows.Count, "B").End(xlUp).Row))
If r <> vbNullString Then
FilePath = "T:\BLUEMAC\Search Paths\PDF MASTER FOLDER\"
ActiveSheet.Hyperlinks.Add Anchor:=r, _
Address:=FilePath & r.Value & ".pdf", TextToDisplay:=r.Value
End If
Next r
End Sub
非常感谢任何帮助。
答案 0 :(得分:1)
更改
Select ID,Name,dbo.GetStatus(ID) From SST_Request
要
<input name="cb" class="cmn-toggle cmn-toggle-round" type="checkbox">
和
if(isset($_REQUEST['cb'])){
//do something
}else{
//do something else
}
要
If Intersect(Columns("B"), Selection) Is Nothing Then Exit Sub
For Each r In Intersect(Selection, Range("B2:B" & _
Cells(Rows.Count, "B").End(xlUp).Row))
答案 1 :(得分:0)
喜欢这个吗?
Sub Hyperlinks()
Dim r As Range
Dim FilePath As String
If Intersect(Columns("B"), Selection) Is Nothing Then Exit Sub
For Each r In Intersect(Selection, Range("B2:B" & Cells(Rows.Count, "B").End(xlUp).Row))
If r <> vbNullString And LCase$(r.Offset(0, 6).value) = "ok" Then
FilePath = "T:\BLUEMAC\Search Paths\PDF MASTER FOLDER\"
ActiveSheet.Hyperlinks.Add Anchor:=r, _
Address:=FilePath & r.Value & ".pdf", TextToDisplay:=r.Value
End If
Next r
End Sub