VBA Not working help improve

SanjayGMusafir

Well-known Member
Joined
Sep 7, 2018
Messages
1,513
Office Version
  1. 2024
Platform
  1. Windows
Dear Experts
I wrote a VBA copy bits from here and there. It worked fine, the day I created, But now it's giving continuous error. It stops at the Red highlighted point and gives error. Can you help me find the error and improve. Thanks a lot ?

Rich (BB code):
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)


    If Target.Name = "Astro - Dosha/Yoga" Then
    Call YogaSort
    Else
    
    If Target.Name = "Astro - Remedies/Gems" Then
    Call RemediesSort
    Else
    
    If Target.Name = "Astro - Prashna" Then
    Call PrashnaSort
    Else
    
    If Target.Name = "Astro - Events" Then
    Call EventsSort
    Else
    
    If Target.Name = "Astro - Muhurata" Then
    Call MuhurataSort
    Else
    
    If Target.Name = "Info - Spriha Sanjay" Then
    Call SprEventsSort
    Else
    
    If Target.Name = "Astro - Mundane" Then
    Call MundaneSort
    Else
    
    If Target.Name = "Astro - Games" Then
    Call GamesSort
    Else
    Do Nothing
    End If
    
End Sub
 

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.
I would think it should be If Target.value=

Or is this a actual named range?

I do not believe that is a proper named Range.
 
Upvote 0
Try it this way....

Code:
Private Sub Workbook_SheetFollowHyperlink(ByVal Target As Hyperlink)
    If Target.Name = "Astro - Dosha/Yoga" Then Call YogaSort
    If Target.Name = "Astro - Remedies/Gems" Then Call RemediesSort
    If Target.Name = "Astro - Prashna" Then Call PrashnaSort
    If Target.Name = "Astro - Events" Then Call EventsSort
    If Target.Name = "Astro - Muhurata" Then Call MuhurataSort
    If Target.Name = "Info - Spriha Sanjay" Then Call SprEventsSort
    If Target.Name = "Astro - Mundane" Then Call MundaneSort
    If Target.Name = "Astro - Games" Then Call GamesSort
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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