finding only numeric values in a worksheet using vb.net?
On 23 Dec., 18:42, "Andrius B." wrote:
Hi all.
Maybe smb could make an advice how to do this:
I have to find all the rows in a Excel worksheet, which contain cell with a
11 digit numeric value.
E.g. two rows each with 3 cells with values:
------------------------------------
Will * *| *Smith *| * 4524574561
Gerry | *Smith *| * *LowStreet 20
------------------------------------
So, the first row should be accepted, and the second - ignored.
I tried different examples using oSheet.Cells.Find(What:=...
but unsuccesfully.
Is there a way to use regular expressions
Thanks in advance.
Hi Andrius
The number in your example has only 10 digits, so that is what I test
for in this macro.
All row numbers that are allowed are placed in DestArray() as I donīt
know what you want do with the result.
Option Base 1
Dim DestArray() As String
Dim tRange As Range
Dim Counter As Integer
Sub Find_Cells()
Set tRange = Selection
Counter = 1
For Each c In tRange
If Len(c.Value) = 10 And IsNumeric(c.Value) = True Then
ReDim Preserve DestArray(Counter)
DestArray(Counter) = c.Row
Counter = Counter + 1
End If
Next
End Sub
Regards
Per
|