Run Macro if Cell Contains...

eli_m

Board Regular
Joined
Jun 2, 2022
Messages
149
Office Version
  1. 365
Platform
  1. Windows
Hi,

In my worksheet, I have Column U that sometimes has "Create Calendar Invite - DATEHERE" in the cell.

I want it so if any cell in Column U has "Create Calendar Invite*" in it and then I click that cell, it runs a Macro I have set up named 'CalendarInvite'

Is there a way to make a hyperlink to run a macro or does it have to be VBA?

I've tried the below with no success:

VBA Code:
If Not Intersect(Selection, Range("U:U")) Is Nothing And Selection.Count = 1 Then
        If InStr(1, Cells(ActiveCell.Row, "U").Value, "Create Calendar Invite*") > 0 Then
            Call CalendarInvite
        End If
    End If


Full code:
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Application.CutCopyMode = False Then
Application.Calculate ' Refresh for Grey Line
End If

If Not Intersect(Selection, Range("U:U")) Is Nothing And Selection.Count = 1 Then
        If InStr(1, Cells(ActiveCell.Row, "U").Value, "Create Calendar Invite*") > 0 Then
            Call CalendarInvite
        End If
    End If

'Check Timeout timer
checktime = True
Lastchange = Now()

End Sub

Thanks in advance!
 
VBA Code:
If Not Target.Find("Create Calendar Invite") Is Nothing Then
That works if I type in the cell "Create Calendar Invite - 02-Dec" it works:
1730170803194.png


but If the formula puts the text in it doesn't work:
1730170832797.png



So I think there's an issue when the formula says it..
 
Upvote 0

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Only other thing I can think of is
VBA Code:
If Not Target.Find("Create Calendar Invite",LookIn:= xlValues) Is Nothing Then
 
Upvote 0
Solution
Only other thing I can think of is
VBA Code:
If Not Target.Find("Create Calendar Invite",LookIn:= xlValues) Is Nothing Then

Sadly that didnt' work either.. I wonder if there is another way to run the macro by clicking the cell if it has Formula Text
 
Upvote 0
The word "Calandar" is definitely a misspelling, and does it actually appear in your formula?
Try correcting it and see if it works

Screenshot 2024-10-29 110611.png
 
Upvote 0
*Giggles*:giggle:
 
Upvote 0

Forum statistics

Threads
1,223,099
Messages
6,170,114
Members
452,302
Latest member
TaMere

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