excel - 超链接 Excel 中的整个列,直到文本“总计”
问题描述
我正在尝试根据该单元格的内容对整个“B”列进行超链接,直到它到达 A 列中的文本“Total”。我正在使用下面的代码,我尝试了 If 条件和 Do 循环,但是我没有得到结果。
顺便提一下,每行后面都有一个空白行,它可以是动态的,因为它基于数据。
任何帮助表示赞赏。
Private Sub Hyperlink_1()
Dim i
Dim file As String
Dim path As String
Dim file1
i = 6
While Range("B" & i).Value + "" <> ""
path = Range("C3").Value & Application.PathSeparator
file = Dir$(path & Range("B" & i).Value & ".*")
file1 = path & file
ActiveSheet.Hyperlinks.Add _
Anchor:=Range("B" & i).Offset(, 0), _
Address:=file1
Range("B" & i).Offset(, 0).Font.Underline = xlUnderlineStyleNone
Range("B" & i).Offset(, 0).Font.Color = -10477568
i = i + 1
Wend
End Sub
解决方案
尝试
Private Sub Hyperlink_1()
Dim I
Dim File As String
Dim Path As String
Dim File1
Dim rTot As Range
Set rTot = Range("A:A").Find("Total")
If Not rTot Is Nothing Then
Path = Range("C3") & Application.PathSeparator
For I = 6 To rTot.Row - 1
If Range("B" & I) <> "" Then
File = Dir$(Path & Range("B" & I) & ".*")
If File <> "" Then
File1 = Path & File
ActiveSheet.Hyperlinks.Add _
Anchor:=Range("B" & I), _
Address:=File1
Range("B" & I).Font.Underline = xlUnderlineStyleNone
Range("B" & I).Font.Color = -10477568
End If
End If
Next I
Else
MsgBox "Total not found", vbCritical, "CRITICAL"
End If
End Sub
推荐阅读
- here-api - 交易追踪 Here maps
- php - 在测试我的算法的所有可能性时减少测试时间的策略
- php - Bad Minute 错误,crontab 文件中的错误,无法安装
- visual-studio-code - VSCode 扩展显示函数
- amazon-web-services - 使用AWS Athena从s3中的csv文件中查询一行来查询导出列表
- c# - 使用 azure DevOps 管道进行 Azure Function 测试
- javascript - 在组件中设置键不会在状态更新时重新渲染组件
- java - 如何在 Java 中用 "" caractére 拆分句子
- java - 将静态值复制到非静态实例中
- c - GCC 编译问题 - 致命错误:找不到 'ld'