Private Sub CommandButton2_Click()
Dim MyPath, Myname As String
Dim i, q, n As Integer
Dim sht As Worksheet
MyPath = TextBox1.Text & "\"
Myname = Dir(MyPath, vbDirectory) '读取指定目录中的第一个文件夹名称
Set sht = ActiveWorkbook.Sheets(1)
n = ActiveSheet.UsedRange.Rows.Count '指定n为最大行数
If TextBox1.Text = "" Then MsgBox ("请输入地址")
Do While Myname <> ""
For i = 2 To n
If Myname <> "." And Myname <> ".." Then
If Myname = sht.Cells(i, 1) Then
sht.Hyperlinks.Add anchor:=sht.Cells(i, 1), Address:=MyPath & Myname & "\"
Else
End If
End If
Next i
Myname = Dir
Loop
End Sub
求大佬帮忙修改为,取一个表格,把第二咧做为链接
Dim MyPath, Myname As String
Dim i, q, n As Integer
Dim sht As Worksheet
MyPath = TextBox1.Text & "\"
Myname = Dir(MyPath, vbDirectory) '读取指定目录中的第一个文件夹名称
Set sht = ActiveWorkbook.Sheets(1)
n = ActiveSheet.UsedRange.Rows.Count '指定n为最大行数
If TextBox1.Text = "" Then MsgBox ("请输入地址")
Do While Myname <> ""
For i = 2 To n
If Myname <> "." And Myname <> ".." Then
If Myname = sht.Cells(i, 1) Then
sht.Hyperlinks.Add anchor:=sht.Cells(i, 1), Address:=MyPath & Myname & "\"
Else
End If
End If
Next i
Myname = Dir
Loop
End Sub
求大佬帮忙修改为,取一个表格,把第二咧做为链接