Cant Find value in formuale- VBA

gogeta1998

New Member
Joined
Mar 21, 2022
Messages
6
Office Version
  1. 365
Platform
  1. Windows
I'm writing a macro to make it such that if a value is found in column B then do one thing, otherwise do another thing. However it doesn't return the correct value because it doesnt look at the the text the formulae outputs.

VBA Code:
Sub Value_Find()

Dim Cell As Range
Columns("B:B").Select
Set Cell = Selection.Find(What:="Please Add Institution", After:=ActiveCell, LookIn:=xlFormulas, _
        LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False)

If Cell Is Nothing Then
    MsgBox "It Works"
Else
    MsgBox "Please Add Institution"
End If



End Sub

so, if I write "Please Add Institution" manually then it returns the correct message box, however if there is a formulae making the cell value "Please Add Institution", then it doesn't print the correct message- instead it prints "It Works".

Please help thanks
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
77,547
Office Version
  1. 365
Platform
  1. Windows
Change this xlFormulasto xlValues
 
Solution

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
77,547
Office Version
  1. 365
Platform
  1. Windows
You're welcome & thanks for the feedback.
 

Forum statistics

Threads
1,175,663
Messages
5,898,756
Members
434,729
Latest member
Tej92

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
Top