|
-
Nov 4th, 2005, 02:56 PM
#1
Thread Starter
Frenzied Member
Excel: How To: Function to identify cells with "*" [RESOLVED]
Esteemed Forum Participants and Lurkers:
===============================
Excel 2003 Functions
I regularly receive a worksheet that has some cells with "*" as the contents of the cell. I need to programmatically find the address of these cells with a function. I have tried the "Match" and "Countif" functions, but they both seem to consider the "*" as a wildcard!
=MATCH("*",A7:E7,0)
=MATCH(CHAR(CODE("*")),A7:E7,0)
=COUNTIF(A7:E7,"*")
Is there some way to turn off the wildcard action of "*"? Is there a simple function to find an occurrence of "*" as the total contents of the cell in a range of cells (row)?
Last edited by Webtest; Nov 28th, 2005 at 11:44 AM.
Reason: RESOLVED
Blessings in abundance,
All the Best,
& ENJOY!
Art . . . . Carlisle, PA . . USA
-
Nov 5th, 2005, 12:15 AM
#2
New Member
Re: Excel: How To: Function to identify cells with "*" ???
I would have expected the first Match function to work. For the CountIf try adding a tilde:
=COUNTIF(A1:A10,"~*")
HTH
-
Nov 28th, 2005, 11:43 AM
#3
Thread Starter
Frenzied Member
Re: Excel: How To: Function to identify cells with "*" ???
I finally bit the bullet and wrote a short function for this one. My 'cell of interest' only contains a single asterisk character. Here is how I solved it:
Code:
(Option Explicit)
'=======================================================================================
'Function to determine if the first cell in a range contains only an asterisk
'
'Pass Range Object which points to the cell to test
'Return Boolean ... False if NOT Asterisk, True if IS ASTERISK
'
Private Function IsAsterisk(aRange As Range) As Boolean
'Set the Function Return to FALSE = NOT an Asterisk
IsAsterisk = False
'Fetch the contents of the cell
With aRange
If IsNumeric(.Value) Or IsEmpty(.Value) Then
'TEST TEST TEST TEST
'MsgBox "Cell is NUMERIC or EMPTY"
'END TEST
Else
'Check to see if this is a single Asterisk character
If Len(.Value) = 1 And Asc(.Value) = 42 Then
'Yes, this IS an ASTERISK - Set the Return Parameter
IsAsterisk = True
'TEST TEST TEST TEST
'MsgBox "This is an asterisk!"
'END TEST
End If
End If
End With
End Function
Last edited by Webtest; Nov 28th, 2005 at 12:04 PM.
Reason: Added "IsNumeric" Test
Blessings in abundance,
All the Best,
& ENJOY!
Art . . . . Carlisle, PA . . USA
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|