PC Review


Reply
Thread Tools Rate Thread

Determining if Cell has Formula

 
 
PosseJohn
Guest
Posts: n/a
 
      26th Nov 2008
I have a worksheet that contains formulas that are linked dynamically to an
outside source. I have created a Workbook_BeforeClose routine that asks the
user if formulas should be removed from the worksheet (to lock in the values
from outside source).

If the formulas have already been removed, I don't want to ask the user
about formulas that have already been removed.

How can I determine if a specific cell contains a formula or an actual value?
 
Reply With Quote
 
 
 
 
Gary Keramidas
Guest
Posts: n/a
 
      26th Nov 2008
maybe one of these:

If ActiveCell.HasFormula = True Then
MsgBox ActiveCell.Address & " contains a formula"
End If


If Range("A1").HasFormula = True Then
MsgBox Range("A1").Address & " contains a formula"
End If

--

Gary
Excel 2003


"PosseJohn" <(E-Mail Removed)> wrote in message
news:E011D5B3-A4A5-453B-B912-(E-Mail Removed)...
>I have a worksheet that contains formulas that are linked dynamically to an
> outside source. I have created a Workbook_BeforeClose routine that asks
> the
> user if formulas should be removed from the worksheet (to lock in the
> values
> from outside source).
>
> If the formulas have already been removed, I don't want to ask the user
> about formulas that have already been removed.
>
> How can I determine if a specific cell contains a formula or an actual
> value?


 
Reply With Quote
 
PosseJohn
Guest
Posts: n/a
 
      26th Nov 2008
Thank you Gary, couldn't recall the 'HasFormula' property. That was exactly
the answer I needed.

Have a great Turkey day!

"Gary Keramidas" wrote:

> maybe one of these:
>
> If ActiveCell.HasFormula = True Then
> MsgBox ActiveCell.Address & " contains a formula"
> End If
>
>
> If Range("A1").HasFormula = True Then
> MsgBox Range("A1").Address & " contains a formula"
> End If
>
> --
>
> Gary
> Excel 2003
>
>
> "PosseJohn" <(E-Mail Removed)> wrote in message
> news:E011D5B3-A4A5-453B-B912-(E-Mail Removed)...
> >I have a worksheet that contains formulas that are linked dynamically to an
> > outside source. I have created a Workbook_BeforeClose routine that asks
> > the
> > user if formulas should be removed from the worksheet (to lock in the
> > values
> > from outside source).
> >
> > If the formulas have already been removed, I don't want to ask the user
> > about formulas that have already been removed.
> >
> > How can I determine if a specific cell contains a formula or an actual
> > value?

>
>

 
Reply With Quote
 
Peter T
Guest
Posts: n/a
 
      26th Nov 2008
Another way if you don't want to loop all cells looking for formulas

Sub test()
Dim rng As Range
Dim ws As Worksheet

Set ws = ActiveSheet
' or say
' Set ws = ActiveWorkbook.Worksheets("Sheet1")

On Error Resume Next
Set rng = ws.Cells.SpecialCells(xlCellTypeFormulas, 23)
On Error GoTo 0

If Not rng Is Nothing Then
MsgBox rng.Count & " formula cells" & vbCr & _
"address of first formula " & rng(1).Address(0, 0), , _
rng.Parent.Name
End If

End Sub

Regards,
Peter T

"PosseJohn" <(E-Mail Removed)> wrote in message
news:E011D5B3-A4A5-453B-B912-(E-Mail Removed)...
>I have a worksheet that contains formulas that are linked dynamically to an
> outside source. I have created a Workbook_BeforeClose routine that asks
> the
> user if formulas should be removed from the worksheet (to lock in the
> values
> from outside source).
>
> If the formulas have already been removed, I don't want to ask the user
> about formulas that have already been removed.
>
> How can I determine if a specific cell contains a formula or an actual
> value?



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
need help with determining a formula =?Utf-8?B?Q2Fs?= Microsoft Excel Worksheet Functions 2 11th Nov 2005 01:49 PM
formula for determining CPU/RAM Mike Microsoft Windows 2000 Terminal Server Applications 3 13th Sep 2004 04:29 AM
Function for determining if cell content is formula vs value Occupant Microsoft Excel Discussion 2 11th Aug 2004 10:31 PM
Determining if cell contains formula or value tapeery Microsoft Excel Worksheet Functions 2 28th Jul 2004 07:48 PM
Determining whether selected cell has value or formula? John Wirt Microsoft Excel Programming 3 31st Jul 2003 04:19 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:54 AM.