我写了一个做Vlookup的VBA。它正在查找索赔号,每个caim在范围的第3列中都有一个超链接,导致声明的详细信息,图片等.Vlookup返回第3列中的相关超链接,但后来我想要一个vbyesno框给出用户可以选择指向Vlookup返回的超链接并查看声明详细信息。 我设法让它工作正常可以引导人们访问网址(我在我的VBA中使用谷歌作为示例)是否可以稍微更改我的VBA而不是谷歌它将根据结果更改超链接VLOOKUP。
这是我写的VBA
Sub check()
On Error GoTo MyerrorHandler:
Dim claim_number As String
Dim here As String
claim_number = InputBox("please enter claim number")
If Len(claim_number) > 0 Then
Set myRange = Range("claims")
Set objShell = CreateObject("Wscript.Shell")
here = Application.WorksheetFunction.VLookup(claim_number, myRange, 3, False)
intMessage = MsgBox("The claim has been partly investigated by Ali. Would"
"you like to view the details of the claim.", _
vbYesNo, "Great news Lee")
If intMessage = vbYes Then
objShell.Run ("www.google.com")
Else
Wscript.Quit
End If
Else
MsgBox "You didn't enter a claim number"
End If
Exit Sub
MyerrorHandler:
If Err.Number = 1004 Then
MsgBox "Claim has not been invsetigated"
End If
End Sub
答案 0 :(得分:0)
感谢帮助人员。我设法解决了这个问题。 我刚刚使用了ThisWorkbook.FollowHyperlink(这里)
如下图所示
Sub check()
On Error GoTo MyerrorHandler
Dim claim_number As String
Dim here As String
claim_number = InputBox("Please enter the claim number")
If Len(claim_number) > 0 Then
Set myrange = Range("claims")
Set objShell = CreateObject("Wscript.Shell")
here = Application.WorksheetFunction.VLookup(claim_number, myrange, 3,
False)
intMessage = MsgBox("This claim has been investigated by Ali. Would you
like to view the details?", _
vbYesNo, "GREAT NEWS LEE")
If intMessage = vbYes Then
ThisWorkbook.FollowHyperlink (here)
Else
Wscript.Quit
End If
Else
MsgBox "You didn't enter a claim number"
End If
Exit Sub
MyerrorHandler:
If Err.Number = 1004 Then
MsgBox "This claim has not been investigated"
End If
End Sub