Solved

Excel VBA Check if Cell has particular Formula (VBA)

Posted on 2015-01-08
4
136 Views
Last Modified: 2015-01-08
Hello,

I'm trying to check if cells have a particular function (subtotal).    I was thinking about basing it on

Function IsFormula(cell_ref As Range)
    IsFormula = cell_ref.HasFormula
End Function
from Mr. Excel but I can't seem to make it work.

Thanks,
0
Comment
Question by:mattfmiller
  • 2
4 Comments
 
LVL 33

Accepted Solution

by:
Norie earned 500 total points
ID: 40539008
Perhaps.
Function IsSubTotalFormula(cell_ref As Range) As Boolean
    If cell_ref.HasFormula Then
        IsSubTotalFormula = InStr(cell_ref.Formula, "SUBTOTAL") > 0
    End If
End Function

Open in new window

0
 
LVL 1

Author Closing Comment

by:mattfmiller
ID: 40539016
Thank you very much.  It was killing me.
0
 
LVL 23

Expert Comment

by:Michael74
ID: 40539017
This will do the trick

Function IsSubTotal(cell_ref As Range)
    If InStr(cell_ref.Formula, "SUBTOTAL") = 0 Then
        IsSubTotal = False
    Else
        IsSubTotal = True
    End If
End Function

Open in new window

0
 
LVL 23

Expert Comment

by:Michael74
ID: 40539020
way too slow, closed before I posted
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now