ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Whether a Cell contains a Formula (https://www.excelbanter.com/excel-discussion-misc-queries/102637-whether-cell-contains-formula.html)

Roger

Whether a Cell contains a Formula
 
What function can be used to determine whether a cell contains a formula?

Thanks in advance for your help.

Roger

Stefi

Whether a Cell contains a Formula
 
Try this UDF:
Function IsFormula(cellref)
IsFormula = Left(Range(cellref).Formula, 1) = "="
End Function

Regards,
Stefi


Roger ezt *rta:

What function can be used to determine whether a cell contains a formula?

Thanks in advance for your help.

Roger


VBA Noob

Whether a Cell contains a Formula
 

A couple of sites which should help you

"Identify formulas using Conditional Formatting "


http://www.j-walk.com/ss/excel/usertips/tip045.htm

http://www.pcmag.com/article2/0,1759,1573749,00.asp

VBA Noob


--
VBA Noob
------------------------------------------------------------------------
VBA Noob's Profile: http://www.excelforum.com/member.php...o&userid=33833
View this thread: http://www.excelforum.com/showthread...hreadid=567403


Bob Phillips

Whether a Cell contains a Formula
 
Stefi,

cellref.HasFormula

built-in property of a range

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Stefi" wrote in message
...
Try this UDF:
Function IsFormula(cellref)
IsFormula = Left(Range(cellref).Formula, 1) = "="
End Function

Regards,
Stefi


"Roger" ezt rta:

What function can be used to determine whether a cell contains a

formula?

Thanks in advance for your help.

Roger




Roger

Whether a Cell contains a Formula
 
Bob:

Thanks for your input. I tried Stefi's suggestion, but somehow I can't get
it to work. It may be because I don't know much about macros.

Basically, I have two columns containing formulas. Any of the two columns
can be overwritten with data. In one of the two columns which was not
overwritten with data, I would like it to be changed to write-protected. In
the third column, I want to know which of the first two columns still has the
formula.

How to achieve this? Thanks again in advance.

Regards,
Roger



"Bob Phillips" wrote:

Stefi,

cellref.HasFormula

built-in property of a range

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Stefi" wrote in message
...
Try this UDF:
Function IsFormula(cellref)
IsFormula = Left(Range(cellref).Formula, 1) = "="
End Function

Regards,
Stefi


"Roger" ezt *rta:

What function can be used to determine whether a cell contains a

formula?

Thanks in advance for your help.

Roger





Bob Phillips

Whether a Cell contains a Formula
 
Add the UDF to a code module and then in the worksheet use

=IF(IsFormula(M1),"M",IF(IsFormula(N1),"N",""))

where I assume M and N are those two columns.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Roger" wrote in message
...
Bob:

Thanks for your input. I tried Stefi's suggestion, but somehow I can't

get
it to work. It may be because I don't know much about macros.

Basically, I have two columns containing formulas. Any of the two columns
can be overwritten with data. In one of the two columns which was not
overwritten with data, I would like it to be changed to write-protected.

In
the third column, I want to know which of the first two columns still has

the
formula.

How to achieve this? Thanks again in advance.

Regards,
Roger



"Bob Phillips" wrote:

Stefi,

cellref.HasFormula

built-in property of a range

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Stefi" wrote in message
...
Try this UDF:
Function IsFormula(cellref)
IsFormula = Left(Range(cellref).Formula, 1) = "="
End Function

Regards,
Stefi


"Roger" ezt rta:

What function can be used to determine whether a cell contains a

formula?

Thanks in advance for your help.

Roger







Roger

Whether a Cell contains a Formula
 
Bob:

I understand the part you have mentioned. I am having some problem with
Stefi's below-mentioned UDF. Can you please write the UDF again? Thanks.

Regards,
Roger



"Bob Phillips" wrote:

Add the UDF to a code module and then in the worksheet use

=IF(IsFormula(M1),"M",IF(IsFormula(N1),"N",""))

where I assume M and N are those two columns.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Roger" wrote in message
...
Bob:

Thanks for your input. I tried Stefi's suggestion, but somehow I can't

get
it to work. It may be because I don't know much about macros.

Basically, I have two columns containing formulas. Any of the two columns
can be overwritten with data. In one of the two columns which was not
overwritten with data, I would like it to be changed to write-protected.

In
the third column, I want to know which of the first two columns still has

the
formula.

How to achieve this? Thanks again in advance.

Regards,
Roger



"Bob Phillips" wrote:

Stefi,

cellref.HasFormula

built-in property of a range

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Stefi" wrote in message
...
Try this UDF:
Function IsFormula(cellref)
IsFormula = Left(Range(cellref).Formula, 1) = "="
End Function

Regards,
Stefi


"Roger" ezt *rta:

What function can be used to determine whether a cell contains a
formula?

Thanks in advance for your help.

Roger







Dave Peterson

Whether a Cell contains a Formula
 
I use this one:

In a General Module:

Option Explicit
Function IsFormula(rng As Range)
IsFormula = rng(1).HasFormula
End Function



Roger wrote:

Bob:

I understand the part you have mentioned. I am having some problem with
Stefi's below-mentioned UDF. Can you please write the UDF again? Thanks.

Regards,
Roger

"Bob Phillips" wrote:

Add the UDF to a code module and then in the worksheet use

=IF(IsFormula(M1),"M",IF(IsFormula(N1),"N",""))

where I assume M and N are those two columns.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Roger" wrote in message
...
Bob:

Thanks for your input. I tried Stefi's suggestion, but somehow I can't

get
it to work. It may be because I don't know much about macros.

Basically, I have two columns containing formulas. Any of the two columns
can be overwritten with data. In one of the two columns which was not
overwritten with data, I would like it to be changed to write-protected.

In
the third column, I want to know which of the first two columns still has

the
formula.

How to achieve this? Thanks again in advance.

Regards,
Roger



"Bob Phillips" wrote:

Stefi,

cellref.HasFormula

built-in property of a range

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Stefi" wrote in message
...
Try this UDF:
Function IsFormula(cellref)
IsFormula = Left(Range(cellref).Formula, 1) = "="
End Function

Regards,
Stefi


"Roger" ezt *rta:

What function can be used to determine whether a cell contains a
formula?

Thanks in advance for your help.

Roger







--

Dave Peterson

Chris Berry

Whether a Cell contains a Formula
 

Roger Wrote:
What function can be used to determine whether a cell contains a
formula?

Thanks in advance for your help.

Roger


I picked up this from Jwalk.com and thought it was pretty neat.


Code:
--------------------
Sub QuickMap()
If TypeName(ActiveSheet) < "Worksheet" Then Exit Sub
' Create object variables for cell subsets
On Error Resume Next
Set FormulaCells = Range("A1").SpecialCells _
(xlFormulas, xlNumbers + xlTextValues + xlLogical)
Set TextCells = Range("A1").SpecialCells(xlConstants, xlTextValues)
Set NumberCells = Range("A1").SpecialCells(xlConstants, xlNumbers)
On Error GoTo 0

' Add a new sheet and format it
Sheets.Add
With Cells
.ColumnWidth = 2
.Font.Size = 8
.HorizontalAlignment = xlCenter
End With

Application.ScreenUpdating = False

' Do the formula cells
If Not IsEmpty(FormulaCells) Then
For Each Area In FormulaCells.Areas
With ActiveSheet.Range(Area.Address)
.Value = "F"
.Interior.ColorIndex = 3
End With
Next Area
End If

' Do the text cells
If Not IsEmpty(TextCells) Then
For Each Area In TextCells.Areas
With ActiveSheet.Range(Area.Address)
.Value = "T"
.Interior.ColorIndex = 4
End With
Next Area
End If

' Do the numeric cells
If Not IsEmpty(NumberCells) Then
For Each Area In NumberCells.Areas
With ActiveSheet.Range(Area.Address)
.Value = "N"
.Interior.ColorIndex = 6
End With
Next Area
End If
End Sub



--------------------


He offers it up as a tip but I think it's also included in his utility
pack.


--
Chris Berry
------------------------------------------------------------------------
Chris Berry's Profile: http://www.excelforum.com/member.php...o&userid=36165
View this thread: http://www.excelforum.com/showthread...hreadid=567403



All times are GMT +1. The time now is 07:42 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com