Conditional "FollowHyperlink"???????

gheyman

Well-known Member
Joined
Nov 14, 2005
Messages
2,330
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!!!!!!!!!!!!!!!!
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
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
 
Upvote 0

Forum statistics

Threads
1,212,143
Messages
6,106,209
Members
448,006
Latest member
oreo2996

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top