LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Looking For A Specific Formula Programmatically

Hi all,

I've written an Excel add-in that allows users to input a list of
formulas that they want "frozen" (i.e. - converted to the formula's
value). For example:

Listbox control on userform contains the following values:
HPVAL
HPEA

userform has Add and Remove buttons to modify this list. userform also
has buttons to freeze the results of these formulas on the current
sheet or throughout the entire workbook.

When the user clicks to freeze button, a routine in the addin looks
through all cells to determine if the formulas in the list are
contained in the cell's formula. If so, the formula is replaced with
its value.

I currently determine if the formula exists in the cell by looking for
the string "=HPVAL(" in the case of the first formula listed above.
So, if the user has typed in "+HPVAL(", the formula is not forzen. Or,
if for some reason the user has a formula something like this:
=IF(A1="My string: =HPVAL(",1,0), then that formula would be frozen,
even though clearly HPVAL used in this context is not a formula, but a
constant string. Another issue is, if the user has the following
formula: =IF(HPVAL(<<stuff here)=1,1,0), then the ENTIRE formula is
converted to its value, and not just the HPVAL part.

All of these problems stem from the fact that I'm looking for "strings"
that represent the formula instead of looking for the formula itself.
Is there a way to examine a cell, determine if a given formula is
utilized in the cell, and freeze its value? Has anyone out there
written an add-in or VBA routine that does the same thing? Your
thoughts are greatly appreciated.

Thanks,
Johnny

 
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
Programmatically add a Formula in a worksheet? circuit_breaker Excel Worksheet Functions 3 July 6th 09 02:53 PM
Formula in only one of many cells not updated when row programmatically inserted above [email protected] Excel Programming 0 November 26th 05 12:20 AM
Changing formula programmatically Mark Excel Programming 1 April 12th 05 02:15 PM
Programmatically increase the row # in a formula Terry V Excel Programming 4 October 8th 04 07:36 PM
Formula produces wrong result when data cells filled programmatically Bob Graham Excel Programming 2 September 12th 03 05:51 AM


All times are GMT +1. The time now is 06:45 PM.

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

About Us

"It's about Microsoft Excel"