?
Solved

Excel VBA Check if Cell has particular Formula (VBA)

Posted on 2015-01-08
4
Medium Priority
?
217 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 35

Accepted Solution

by:
Norie earned 2000 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:Michael Fowler
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:Michael Fowler
ID: 40539020
way too slow, closed before I posted
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
Microsoft's Excel has many features that most people will never need nor take advantage of.  Conditional formatting is one feature that you may find a necessity once you start using it.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

850 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