+ Reply to Thread
Results 1 to 6 of 6

IsNumeric

Hybrid View

  1. #1
    Registered User
    Join Date
    06-18-2010
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2003
    Posts
    4

    IsNumeric

    Hi, i changed the code, it s a lot easier to understand that way, it looks like the Elseif doesn t apply when i encounter letters in a cell, so i get an error type mismatch in those case and i just wanted the code to color cells that have letters in colorindex 5...

    hope some1 can help, thank you


    If NumberButton Then
            
            'fonction if au cas où inverse est coché
            If CheckBox1.Value = True Then
        
                For Each vCellules2 In Range(RefEdit2.Value)
                    For Each vCellules1 In Range(RefEdit1.Value)
                    
                                
                    vCellules1.Replace _
                    What:=" ", Replacement:="", _
                    SearchOrder:=xlByColumns, MatchCase:=True
        
                    vCellules2.Replace _
                    What:=" ", Replacement:="", _
                    SearchOrder:=xlByColumns, MatchCase:=True
                                                                        
                        If vCellules1.Interior.ColorIndex = xlNone _
                        And vCellules2.Interior.ColorIndex = xlNone _
                        And IsNumeric(vCellules1) = True _
                        And IsNumeric(vCellules2) = True _
                        And (vCellules1.Value - (vCellules2.Value * -1)) <= (CDbl(TextBox1.Value)) _
                        And ((vCellules2.Value * -1) - (vCellules1.Value)) <= (CDbl(TextBox1.Value)) _
                        And vCellules1.Text <> "" _
                        And vCellules1.Address <> vCellules2.Address Then
                        vCellules1.Interior.Color = RGB(Rnd * 255, Rnd * 255, Rnd * 255)
                        vCellules2.Interior.Color = vCellules1.Interior.Color
                        
                        ElseIf IsNumeric(vCellules1) = False Or IsNumeric(vCellules2) = False Then
                        vCellules1.Interior.ColorIndex = 5
                        vCellules2.Interior.ColorIndex = 5
                        
                        End If
                    Next vCellules1
                Next vCellules2
                    
            Else
            'Else du CheckBox1 donc si inverse non coché
            
            For Each vCellules2 In Range(RefEdit2.Value)
                    For Each vCellules1 In Range(RefEdit1.Value)
                                    
                    vCellules1.Replace _
                    What:=" ", Replacement:="", _
                    SearchOrder:=xlByColumns, MatchCase:=True
        
                    vCellules2.Replace _
                    What:=" ", Replacement:="", _
                    SearchOrder:=xlByColumns, MatchCase:=True
                                        
                        If vCellules1.Interior.ColorIndex = xlNone _
                        And vCellules2.Interior.ColorIndex = xlNone _
                        And IsNumeric(vCellules1) = True _
                        And IsNumeric(vCellules2) = True _
                        And (vCellules1.Value - (vCellules2.Value)) <= (CDbl(TextBox1.Value)) _
                        And ((vCellules2.Value) - (vCellules1.Value)) <= (CDbl(TextBox1.Value)) _
                        And vCellules1 <> "" _
                        And vCellules2 <> "" _
                        And vCellules1.Address <> vCellules2.Address Then
                        vCellules1.Interior.Color = RGB(Rnd * 255, Rnd * 255, Rnd * 255)
                        vCellules2.Interior.Color = vCellules1.Interior.Color
                        
                        ElseIf IsNumeric(vCellules1) = False Or IsNumeric(vCellules2) = False Then
                        vCellules1.Interior.ColorIndex = 5
                        vCellules2.Interior.ColorIndex = 5
                                            
                        End If
                    Next vCellules1
                Next vCellules2
                                                 
            End If
    End If
        
            
        
        Unload MatchingMacro
    End Sub
    Last edited by Risdell; 06-18-2010 at 12:42 PM.

  2. #2
    Registered User
    Join Date
    06-18-2010
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Is Numeric problem

    message posted twice ><
    Last edited by Risdell; 06-18-2010 at 11:01 AM.

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Is Numeric problem

    Welcome to the forum.

    Please take a few minutes to read the forum rules, and then edit your post to add CODE tags.

    Thanks.
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Registered User
    Join Date
    06-18-2010
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: IsNumeric

    i managed to solve my problem nvm,

    thanks anyways

  5. #5
    Registered User
    Join Date
    06-18-2010
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: IsNumeric

    i managed to solve my problem nvm,

    thanks anyways

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: IsNumeric

    Your post does not comply with Rule 9 of our Forum RULES. If you solve a problem yourself before anyone else has responded, please take a moment to describe your solution, chances are some other member will benefit. And please never edit a thread in which someone else has responded.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1