Question and need help

Ks1102

Well-known Member
Joined
Jan 8, 2008
Messages
689
Hi, pls help
Question If the range cells contents anything how would I just only get the value in that which number = 4 digi.
For example
Cells (1,1).value = (Wellington 0930 Mr.Roger )

Cells (2,2) = cells(1,1)……don’t know how to present the statement !!! Result = 0930

Do any idea?
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
You could create your own function. Put this in a new module:

Code:
Option Explicit

Function GetNumber(rng As Range) As Double
Dim var As Variant
Dim l As Long
var = Split(rng, " ")
For l = LBound(var) To UBound(var)
    If IsNumeric(var(l)) Then
        
        GetNumber = var(l)
        Exit Function
    
    End If
    
Next l
End Function

Then use it like this on your worksheet =GetNumber(A1)
 
Upvote 0
You could create your own function. Put this in a new module:

Code:
Option Explicit

Function GetNumber(rng As Range) As Double
Dim var As Variant
Dim l As Long
var = Split(rng, " ")
For l = LBound(var) To UBound(var)
    If IsNumeric(var(l)) Then
        
        GetNumber = var(l)
        Exit Function
    
    End If
    
Next l
End Function

Then use it like this on your worksheet =GetNumber(A1)

Thanks very much as it very imaging
 
Upvote 0
Thanks very much as it very imaging

May i asked help again as Error below what i built for module as
Sub P()
Dim GetNumber As WorksheetFunction
For I = 1 To 13
Cells(I, 5) = WorksheetFunction.GetNumber.Cells(I, 4)
Next I
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,046
Messages
6,122,855
Members
449,096
Latest member
Erald

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top