• DİKKAT

    DOSYA İndirmek/Yüklemek için ÜCRETLİ ALTIN ÜYELİK Gereklidir!
    Altın Üyelik Hakkında Bilgi

Hücrenin içeriğinde Sayısal Bir Değer olup olmadığının tespit dilmesi

tamer42

Destek Ekibi
Destek Ekibi
Katılım
11 Mart 2005
Mesajlar
3,202
Excel Vers. ve Dili
Office 2013 İngilizce
Merhaba,

Hücrenin Sayısal Bir Değer İçerip İçermediğinin Tespit Edilmesi için aşağıdaki kod hücre sadece sayısal veri içeriyorsa çalışıyor,

yalnız harf ve rakam karışık olduğunda da ; rakam içeriyorsa sonuç almamız için nasıl bir düzenleme yapmamız gerekecektir?

Örnek: Hücre içeriği "abc12d5ef" olduğunda, burada sayısal veri var, bu durumda sayısal veri olduğunun tespitini nasıl yapabiliriz?


Kod:
Sub InfoExample22()

Dim cell As Range

For Each cell In Selection

If Not IsEmpty(cell) And IsNumeric(cell.Value) Then

MsgBox cell.Address

End If

Next
End Sub

Teşekkürler,

iyi hafta sonları...
 
Deneyiniz.

C++:
Sub InfoExample22()
    Dim cell As Range, X As Byte
    
    For Each cell In Selection
        If Not IsEmpty(cell) Then
            For X = 0 To 9
                If InStr(1, cell.Value, X) > 0 Then
                    MsgBox cell.Address
                    Exit For
                End If
            Next
        End If
    Next
End Sub
 
Alternatif:
Kod:
Sub InfoExample22()

    Dim cell As Range, r As Object
  
    Set r = CreateObject("VBscript.RegExp")
    r.Global = True
    r.Pattern = "[^0-9]"
  
    For Each cell In Selection
        If r.Replace(cell, "") <> "" Then MsgBox cell.Address
    Next
  
End Sub
 
Sub InfoExample22() Dim cell As Range, X As Byte For Each cell In Selection If Not IsEmpty(cell) Then For X = 0 To 9 If InStr(1, cell.Value, X) > 0 Then MsgBox cell.Address Exit For End If Next End If Next End Sub
Teşekkür ederim Korhan Hocam
 
Bunlar da başka alternatifler;

C++:
Sub InfoExample22()
    Dim cell As Range
  
    For Each cell In Selection
        If Not IsEmpty(cell) Then
            If cell.Value Like "*[0-9]*" Then MsgBox cell.Address
        End If
    Next
End Sub

C++:
Sub InfoExample22()
    Dim cell As Range
   
    For Each cell In Selection
        If Not IsEmpty(cell) Then
            If Evaluate("=COUNT(FIND({0,1,2,3,4,5,6,7,8,9},""" & cell.Value & """,1))") Then MsgBox cell.Address
        End If
    Next
End Sub
 
A1 için,

Kod:
=BAĞ_DEĞ_SAY(BUL({0;1;2;3;4;5,6;7;8;9};A1))
 
"A1" İçin
Alternatif:
Kod:
=BAĞ_DEĞ_SAY(BUL({0\1\2\3\4\5\6\7\8\9};A1))

=EĞER(BAĞ_DEĞ_SAY(BUL({0\1\2\3\4\5\6\7\8\9};A1))>0=DOĞRU;"RAKAM VAR";"RAKAM YOK")
 
Kod:
Sub test()
    Cells.SpecialCells(xlCellTypeConstants, 23).Interior.ColorIndex = 3
    Cells.SpecialCells(xlCellTypeFormulas, 23).Interior.ColorIndex = 3
End Sub

Tamer42 uzmanım, hücreleri renklendiren bu kodları da deneyebilirsiniz
 
Geri
Üst