LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default finding only numeric values in a worksheet using vb.net?

I don't think you can use Find to find the cells and Find doesn't support
Regular Expressions. Try code like

Function GetValues(InRange As Range, Length As Long) As Range
Dim Res As Range
Dim R As Range

For Each R In InRange.Cells
If IsNumeric(R.Text) = True Then
If Len(R.Text) = Length Then
If Res Is Nothing Then
Set Res = R
Else
Set Res = Application.Union(Res, R)
End If
End If
End If
Next R

Set GetValues = Res
End Function

You can then call this function with code like:

Sub AAA()
Dim R As Range
Dim RR As Range
Set RR = GetValues(InRange:=Range("A1:A10"), Length:=11)
If RR Is Nothing Then
Debug.Print "NOT FOUND"
Else
For Each R In RR
Debug.Print R.Address, R.Text
Next R
End If
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)



"Andrius B." wrote in message
...
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.


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Finding NEXT to last, non zero numeric value in a row gergster Excel Worksheet Functions 3 April 16th 10 01:58 PM
TO DELETE ONLY NUMERIC VALUES IN A CHARACTER AND NUMERIC CELL IN ramesh k. goyal - abohar[_2_] Excel Discussion (Misc queries) 1 October 28th 09 06:50 AM
finding only cells with a numeric value Eelinla Excel Discussion (Misc queries) 3 April 21st 07 07:01 PM
Return Numeric Labels that have different Numeric Values Sam via OfficeKB.com Excel Worksheet Functions 8 December 3rd 06 02:06 AM
Finding the mode (alpha numeric) Jamesy Excel Discussion (Misc queries) 3 July 26th 05 03:12 PM


All times are GMT +1. The time now is 09:12 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright Đ2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"