Solved

Excel VBA Check if Cell has particular Formula (VBA)

Posted on 2015-01-08
4
145 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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

777 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