Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Get numbers from cell

thank you worked perfectly

"Dana DeLouis" wrote:

001
1020


Hi. Same idea as Mike's, but this idea only returns the first set of
numbers, and converts the number 1 (001) to a string to keep it the string
001.
This works on a Selection.

Sub FirstNumbersOnly()
Dim RegExp As Object
Dim Numbers As Object
Dim Cell As Range
Dim PreChar As String 'Force String

Set RegExp = CreateObject("Vbscript.RegExp")
PreChar = Chr(39)

With RegExp
.Global = True
.Pattern = "\d+"

For Each Cell In Selection.Cells
If .Test(Cell.Value) Then
Set Numbers = .Execute(Cell.Value)
Cell(1, 2) = PreChar & Numbers(0)
Else
Cell(1, 2) = vbNullString
End If
Next Cell
End With
Set Numbers = Nothing
Set RegExp = Nothing
End Sub

--
Dana DeLouis


"Get Numbers" wrote in message
...
001
1020

"Ron Coderre" wrote:

In addition to the source values:
almJAL_001
almYFI_1020A_1

Can you let us know what the end result should be?
001? or...1?
1020? or...1020A1? or....10201?
--------------------------

Regards,

Ron
Microsoft MVP (Excel)
(XL2003, Win XP)

"Get Numbers" <Get wrote in message
...
I need to extract the numbers from a given cell to an adjacent cell.
Examples of cell values below.

almJAL_001
almYFI_1020A_1




Reply
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
add multiple numbers in one cell with those numbers remaining visi TD Excel Worksheet Functions 7 May 28th 09 09:41 PM
how to extract numbers from imported cell with text and numbers? jyin Excel Discussion (Misc queries) 3 March 28th 07 01:14 PM
Help! How do you get excel to find the x(changes daily, marked in a cell from another formula) highest numbers in a group of numbers and sum them up? C-Man23 Excel Worksheet Functions 3 January 19th 06 09:52 AM
Help! How do you get excel to find the x(changes daily, marked in a cell from another formula) highest numbers in a group of numbers and sum them up? C-Man23 Excel Worksheet Functions 1 January 9th 06 01:23 PM
Populating a cell with numbers without numbers being formula-based?? StargateFanFromWork Excel Programming 4 July 14th 04 01:03 PM


All times are GMT +1. The time now is 06:43 PM.

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"