Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Determining if Cell has Formula

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?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 364
Default Determining if Cell has Formula

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" wrote in message
...
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?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Determining if Cell has Formula

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" wrote in message
...
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?



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Determining if Cell has Formula

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" wrote in message
...
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
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
Determining formula reference type [email protected] Excel Programming 0 June 14th 07 05:45 PM
Variable determining formula natelr Excel Discussion (Misc queries) 2 June 28th 06 12:27 AM
need help with determining a formula Cal Excel Worksheet Functions 2 November 11th 05 01:49 PM
Need help determining formula [email protected] Excel Programming 2 August 26th 05 05:38 PM
Determining whether selected cell has value or formula? John Wirt Excel Programming 3 July 31st 03 04:19 AM


All times are GMT +1. The time now is 01:19 AM.

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"