السلام عليكم
لدي العمود A فيه ارقام و صيغ
اريد كود لتحديد الخلايا التي تحتوي على ارقام فقط(وهي خلايا متجاوره) دون التي تحتوي على صيغ
عثرت على كود يختار الخلايا غير الفارغه لكن المشكله انه يعتبر الخليه التي تحتوي على صيغه غير فارغه
Sub Select_nonBlank()
Dim FutureRow As Long, CurrRow As Long
Dim col As Integer, nwRow As Long
Dim nonBlank As Range
col = ActiveCell.Column
If Cells(1, col).End(xlDown).Row >= 65536 Then
Exit Sub
End If
' initialize nonblank with first nonblank cells
If Cells(1, col) <> "" Then
If Cells(2, col) <> "" Then
Set nonBlank = Range(Cells(1, col), _
Cells(1, col).End(xlDown))
Else
Set nonBlank = Cells(1, col)
End If
Else
nwRow = Cells(1, col).End(xlDown).Row
If Cells(nwRow + 1, col) = "" Then
Set nonBlank = Cells(nwRow, col)
Else
Set nonBlank = Range(Cells(1, col).End(xlDown), _
Cells(1, col).End(xlDown).End(xlDown))
End If
End If
CurrRow = nonBlank.Rows(nonBlank.Rows.Count).Row + 1
If CurrRow < 65536 Then
FutureRow = Cells(CurrRow, col).End(xlDown).Row
Else
FutureRow = 65536
End If
While FutureRow < 65536
nwRow = Cells(CurrRow, col).End(xlDown).Row
If Cells(nwRow + 1, col) = "" Then
Set nonBlank = Union(nonBlank, Cells(nwRow, col))
CurrRow = nwRow + 1
Else
Set nonBlank = Union(nonBlank, _
Range(Cells(CurrRow, col).End(xlDown), _
Cells(CurrRow, col).End(xlDown).End(xlDown)))
CurrRow = Cells(CurrRow, col).End(xlDown) _
.End(xlDown).Row + 1
End If
If CurrRow > 65536 Then
FutureRow = 65536
Else
FutureRow = Cells(CurrRow, col).End(xlDown).Row
End If
Wend
nonBlank.Select
End sub
]