Conditional "FollowHyperlink"???????

gheyman

Well-known Member
Joined
Nov 14, 2005
Messages
1,782
Office Version
  1. 365
Platform
  1. Windows
I need to enter a condition -

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)

If Range("Z84") > 1 And
Range("D10") = "" Then
UserForm69.Show
End If


- to meet before the hyperlink takes you to its destination. The problem is the this is a "FollowHyperlink" action. It takes me to the next page and then displays the Userform. Basically I dont want the user to be able to leave the page via hyperlink if the two conditions above are not met.

HELP!!!!!!!!!!!!!!!!
 

Some videos you may like

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

erik.van.geit

MrExcel MVP
Joined
Feb 1, 2003
Messages
17,832
Hi, gheyman,
this is not really my favorite kind of code
let's call it a workaround
try this to check if it does what you would like
Code:
Option Explicit

Public PrevSel As Range 'previous selection

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Erik Van Geit
'051116 0026

Dim hyp As String
Dim Cell As Range
Dim ThisCell As Range


If Selection.Count > 1 Then GoTo skip

Set ThisCell = Target

On Error Resume Next
hyp = Target.Hyperlinks(1).SubAddress
On Error GoTo 0

    If Not hyp = "" Then
    Set Cell = ActiveSheet.Range(Right(hyp, Len(hyp) - InStr(1, hyp, "!")))
        If Range("Z84") > 1 And Range("D10") = "" Then
            If PrevSel Is Nothing Then
            Application.Goto reference:=ThisCell.Offset(1, 0)
            Else
            Application.Goto reference:=PrevSel
            End If
        UserForm69.Show 
        End If
    End If
skip:
Set PrevSel = ActiveCell
End Sub
kind regards,
Erik
 

Watch MrExcel Video

Forum statistics

Threads
1,118,911
Messages
5,575,001
Members
412,633
Latest member
simon_elvin
Top