Results 1 to 3 of 3

Thread: Excel: How To: Function to identify cells with "*" [RESOLVED]

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    May 2004
    Location
    Carlisle, PA
    Posts
    1,045

    Resolved 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

  2. #2
    New Member
    Join Date
    Apr 2004
    Posts
    12

    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

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    May 2004
    Location
    Carlisle, PA
    Posts
    1,045

    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
  •  



Click Here to Expand Forum to Full Width