VBA先做一个Vlookup,然后做一个vbyesno框

VBA先做一个Vlookup,然后做一个vbyesno框,vba,excel,hyperlink,vlookup,Vba,Excel,Hyperlink,Vlookup,我已经编写了一个VBA,它可以执行Vlookup。它正在查找索赔编号,每个caim在范围的第3列中都有一个超链接,该超链接指向索赔的详细信息、图片等。Vlookup返回第3列中的相关超链接,但我希望有一个vbyesno框,让用户可以选择指向Vlookup返回的超链接并查看索赔详细信息。 我已经设法让它工作正常,可以将人们引导到一个网址(我在我的VBA中使用了google作为示例)是否可以稍微更改我的VBA,以便根据vlookup的结果而不是google更改超链接 这是我写的VBA Sub che

我已经编写了一个VBA,它可以执行Vlookup。它正在查找索赔编号,每个caim在范围的第3列中都有一个超链接,该超链接指向索赔的详细信息、图片等。Vlookup返回第3列中的相关超链接,但我希望有一个vbyesno框,让用户可以选择指向Vlookup返回的超链接并查看索赔详细信息。 我已经设法让它工作正常,可以将人们引导到一个网址(我在我的VBA中使用了google作为示例)是否可以稍微更改我的VBA,以便根据vlookup的结果而不是google更改超链接

这是我写的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

谢谢你们的帮助。我已经设法解决了这个问题。 我刚刚使用了此工作簿。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

结束Sub

谢谢大家的帮助。我已经设法解决了这个问题。 我刚刚使用了此工作簿。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

在不知道源数据的情况下,我可以告诉您,您可以使用
cell.Hyperlinks(1.address)
从单元格中获取超链接地址,因此
objShell.Run(cell.Hyperlinks(1.address)
应该可以做到这一点。只需将
单元格
替换为工作表中的超链接所在位置。超链接所在的单元格将发生更改。Vlookup将返回包含相关超链接的单元格。我怎样才能使用Vlookup结果单元格获取超链接
objShell.Run(在这里)
?是的。我需要它转到(此处)并指向该单元格中的超链接假设
myrange
从第1行开始,尝试以下操作:
objShell.Run(单元格(Application.WorksheetFunction.Match(claim_number,myrange,0),3)。超链接(1.Address)
,而不知道源数据,我可以告诉您,您可以使用
cell.Hyperlinks(1.address)
从单元格中获取超链接地址,因此
objShell.Run(cell.Hyperlinks(1.address)
应该可以做到这一点。只需将
单元格
替换为工作表中的超链接所在位置。超链接所在的单元格将发生更改。Vlookup将返回包含相关超链接的单元格。我怎样才能使用Vlookup结果单元格获取超链接
objShell.Run(在这里)
?是的。我需要它转到(此处)并指向该单元格中的超链接假设
myrange
从第1行开始,请尝试以下操作:
objShell.Run(单元格(Application.WorksheetFunction.Match(索赔编号,myrange,0),3)。超链接(1.Address)