#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default HasFormula

Bob Phillips and maybe many others have provided a UDF like

Function HASFORMULA(rng As Range)
If rng.Count = 1 Then
HASFORMULA = rng.HASFORMULA
Else
HASFORMULA = CVErr(xlErrRef)
End If
End Function

Can this function be changed to show an array of TRUE/FALSE values
reflecting whether cells in a range holds formulas or not?

Hans Knudsen


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default HasFormula

Function GOTFORMULA(rng As Range)
' array enter with Ctr-Shift Enter
Dim arr()
On Error GoTo errH
With rng
ReDim arr(1 To .Rows.Count, 1 To .Columns.Count)
For C = 1 To UBound(arr, 2)
For r = 1 To UBound(arr)
arr(r, C) = .Cells(r, C).HasFormula
Next
Next
End With
GOTFORMULA = arr
Exit Function
errH:
GOTFORMULA = CVErr(xlErrRef)
End Function

Regards,
Peter T


"HK" wrote in message
...
Bob Phillips and maybe many others have provided a UDF like

Function HASFORMULA(rng As Range)
If rng.Count = 1 Then
HASFORMULA = rng.HASFORMULA
Else
HASFORMULA = CVErr(xlErrRef)
End If
End Function

Can this function be changed to show an array of TRUE/FALSE values
reflecting whether cells in a range holds formulas or not?

Hans Knudsen




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default HasFormula

Thank you very much.
Hans


"Peter T" <peter_t@discussions skrev i meddelelsen
...
Function GOTFORMULA(rng As Range)
' array enter with Ctr-Shift Enter
Dim arr()
On Error GoTo errH
With rng
ReDim arr(1 To .Rows.Count, 1 To .Columns.Count)
For C = 1 To UBound(arr, 2)
For r = 1 To UBound(arr)
arr(r, C) = .Cells(r, C).HasFormula
Next
Next
End With
GOTFORMULA = arr
Exit Function
errH:
GOTFORMULA = CVErr(xlErrRef)
End Function

Regards,
Peter T


"HK" wrote in message
...
Bob Phillips and maybe many others have provided a UDF like

Function HASFORMULA(rng As Range)
If rng.Count = 1 Then
HASFORMULA = rng.HASFORMULA
Else
HASFORMULA = CVErr(xlErrRef)
End If
End Function

Can this function be changed to show an array of TRUE/FALSE values
reflecting whether cells in a range holds formulas or not?

Hans Knudsen




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default HasFormula

I should of course have declared ALL the variables

Function GOTFORMULA(rng As Range)
' array enter with Ctr-Shift Enter
Dim r As Long, c As long
Dim arr()

Peter T

"Peter T" <peter_t@discussions wrote in message
...
Function GOTFORMULA(rng As Range)
' array enter with Ctr-Shift Enter
Dim arr()
On Error GoTo errH
With rng
ReDim arr(1 To .Rows.Count, 1 To .Columns.Count)
For C = 1 To UBound(arr, 2)
For r = 1 To UBound(arr)
arr(r, C) = .Cells(r, C).HasFormula
Next
Next
End With
GOTFORMULA = arr
Exit Function
errH:
GOTFORMULA = CVErr(xlErrRef)
End Function

Regards,
Peter T


"HK" wrote in message
...
Bob Phillips and maybe many others have provided a UDF like

Function HASFORMULA(rng As Range)
If rng.Count = 1 Then
HASFORMULA = rng.HASFORMULA
Else
HASFORMULA = CVErr(xlErrRef)
End If
End Function

Can this function be changed to show an array of TRUE/FALSE values
reflecting whether cells in a range holds formulas or not?

Hans Knudsen






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default HasFormula

It is unclear how you intend to use the function you asked for. Would it be
enough if the function simply told you if every cell in the specified range
hold formulas or not? This function will return TRUE if every cell in the
range holds a formula and FALSE otherwise...

Function RangeHasFormulas(Rng As Range) As Boolean
Dim R As Range
For Each R In Rng
If Not R.HasFormula Then Exit Function
Next
RangeHasFormulas = True
End Function

--
Rick (MVP - Excel)


"HK" wrote in message
...
Bob Phillips and maybe many others have provided a UDF like

Function HASFORMULA(rng As Range)
If rng.Count = 1 Then
HASFORMULA = rng.HASFORMULA
Else
HASFORMULA = CVErr(xlErrRef)
End If
End Function

Can this function be changed to show an array of TRUE/FALSE values
reflecting whether cells in a range holds formulas or not?

Hans Knudsen





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default HasFormula

To Rick Rothstein
Peter T's function does exactly what I wanted.

Hans


"Rick Rothstein" skrev i meddelelsen
...
It is unclear how you intend to use the function you asked for. Would it
be enough if the function simply told you if every cell in the specified
range hold formulas or not? This function will return TRUE if every cell
in the range holds a formula and FALSE otherwise...

Function RangeHasFormulas(Rng As Range) As Boolean
Dim R As Range
For Each R In Rng
If Not R.HasFormula Then Exit Function
Next
RangeHasFormulas = True
End Function

--
Rick (MVP - Excel)


"HK" wrote in message
...
Bob Phillips and maybe many others have provided a UDF like

Function HASFORMULA(rng As Range)
If rng.Count = 1 Then
HASFORMULA = rng.HASFORMULA
Else
HASFORMULA = CVErr(xlErrRef)
End If
End Function

Can this function be changed to show an array of TRUE/FALSE values
reflecting whether cells in a range holds formulas or not?

Hans Knudsen



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Conditional Formating Bug when using HasFormula UDF Martin Brader Excel Programming 1 August 25th 06 08:06 AM
simple... HasFormula ? mark kubicki Excel Programming 5 May 11th 06 04:01 PM
Help with ActiveCell.HasFormula Paul Fenton[_2_] Excel Programming 0 April 20th 06 03:03 PM
HasFormula John Wirt[_12_] Excel Programming 1 February 7th 06 04:07 AM
HasFormula protect cell SIGE Excel Programming 7 May 19th 05 05:24 PM


All times are GMT +1. The time now is 05:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"