Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default Constant in Formula

Hi there,

IS it possible to select all cells on the active sheet that contains
constants in my formulas?

EG:
=A1+A2 = do not select
=A1+A2+100 = select
=100*A1-A2 =select

(=A1+Max(3,4)= not select?!)



Quoting Ivan Maola's moto: Can do!
I hope you can show me ... :o)
Brgds Sige

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Constant in Formula

Hi Sige,

Try something like:

'=================
Sub Tester01()
Dim rng As Range
Dim rng2 As Range
Dim rCell As Range
Dim arr As Variant
Dim sStr As String
Dim i As Long

arr = Array("/", "~*", "+", "-", "", "<", "=", "^")

On Error Resume Next 'In case no formulas!
Set rng = ActiveSheet.UsedRange.SpecialCells(xlFormulas)
On Error GoTo 0

If Not rng Is Nothing Then
For Each rCell In rng.Cells
For i = LBound(arr) To UBound(arr)
sStr = "*" & arr(i) & "[0-9]*"
If rCell.Formula Like sStr Then
If Not rng2 Is Nothing Then
Set rng2 = Union(rng2, rCell)
Else
Set rng2 = rCell
End If
End If
Next i
Next rCell
Else
'No formulas found
End If

rng2.Select

End Sub
'<<=================

---
Regards,
Norman



"Sige" wrote in message
oups.com...
Hi there,

IS it possible to select all cells on the active sheet that contains
constants in my formulas?

EG:
=A1+A2 = do not select
=A1+A2+100 = select
=100*A1-A2 =select

(=A1+Max(3,4)= not select?!)



Quoting Ivan Maola's moto: Can do!
I hope you can show me ... :o)
Brgds Sige



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default Constant in Formula

Wonderfull Norman!!!

Possible to catch these as well?

=60*A1 gets trapped but not

=A1*60

*-*-*-*-*-*-*-*-*-*-*
=100/+-A1 = OK
=A1/+-100 = OK

:o) Sige

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Constant in Formula

Hi Sige,

Possible to catch these as well?

=60*A1 gets trapped but not

=A1*60


Change:

arr = Array("/", "~*", "+", "-", "", "<", "=", "^")


to:

arr = Array("/", "~*", "+", "-", "", "<", "=", "^", "[*]")


---
Regards,
Norman



"Sige" wrote in message
ps.com...
Wonderfull Norman!!!

Possible to catch these as well?

=60*A1 gets trapped but not

=A1*60

*-*-*-*-*-*-*-*-*-*-*
=100/+-A1 = OK
=A1/+-100 = OK

:o) Sige



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Constant in Formula

Hi Sige,

arr = Array("/", "~*", "+", "-", "", "<", "=", "^", "[*]")


To add, the multiplication operator '*' is enclosed in square brackets so
that the Like operator can distingish it as a unique character, and not as
the Like operator's '*' wildcard character.

---
Regards,
Norman



"Norman Jones" wrote in message
...
Hi Sige,

Possible to catch these as well?

=60*A1 gets trapped but not

=A1*60


Change:

arr = Array("/", "~*", "+", "-", "", "<", "=", "^")


to:

arr = Array("/", "~*", "+", "-", "", "<", "=", "^", "[*]")


---
Regards,
Norman



"Sige" wrote in message
ps.com...
Wonderfull Norman!!!

Possible to catch these as well?

=60*A1 gets trapped but not

=A1*60

*-*-*-*-*-*-*-*-*-*-*
=100/+-A1 = OK
=A1/+-100 = OK

:o) Sige







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 535
Default Constant in Formula

Hi Norman,

To add, the multiplication operator '*' is enclosed in square brackets so
that the Like operator can distingish it as a unique character, and not as
the Like operator's '*' wildcard character.


Devious. Wouldn't you need to add "(" and ")" too?

Regards,

Jan Karel Pieterse
Excel MVP
http://www.jkp-ads.com

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
Formula vs. Constant rk0909 Excel Discussion (Misc queries) 24 January 14th 10 06:34 PM
formula vs constant rk0909 Excel Discussion (Misc queries) 1 January 14th 10 03:03 AM
Set a constant from a formula in VBA Ed Excel Discussion (Misc queries) 1 December 1st 06 01:31 AM
Formula Constant dale1948 Excel Worksheet Functions 2 November 2nd 05 09:44 PM
Constant Value in formula. Nomad Excel Worksheet Functions 1 March 28th 05 08:53 PM


All times are GMT +1. The time now is 11:27 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"