Extracting and then Converting a 7 digit number to a 10 digit number within a text string

kawliga

New Member
Joined
Feb 3, 2017
Messages
16
Hello,

We have large files that require we change customers 7 digit call forwarding number to a new 10 digit number (adding an area code). I have tried severl formulas but so far no luck.

Example:

CWT DGT PIC 0222 Y CFDA N NSCR 1 A 24 FIXRING 5936245 CFBL N NSCR 1 A

In this example I would like to extract and change the 5936245 to 3155936245.

The 7 digit number is not always the same so I need to extract ANY 7 digit number and then add the 315.

Thanks In Advance
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
No, there should not be any other "CF" text prior to the initial "CF"
Sorry, one more question... where is your existing data located at (Column A perhaps) and where should the results... text with 315 prepended (Column B perhaps) and the text that starts with CF, especially if more than one (Columns C, D, etc. perhaps) go at?
 
Upvote 0
They are in 3 columns and would like the result to be in Column D


Example:


A B C
4022311 CWT 3WC DGT SUPPRESS PUBLIC Y Y PIC 0893 Y SC2 CFW C NSCR 1 I $ CFDA N NSCR 1 A 24 FIXRING 5936245 CFBL N NSCR 1 A 5936245 LPIC 0893 Y
 
Upvote 0
They are in 3 columns and would like the result to be in Column D

Column A has the Phone Number
Column B has one string with a possible CF
Column C has one string with a possible CF

Results in Column D would be great

Thanks
 
Upvote 0
They are in 3 columns and would like the result to be in Column D

Column A has the Phone Number
Column B has one string with a possible CF
Column C has one string with a possible CF

Results in Column D would be great
They are in 3 columns and would like the result to be in Column D

Example:

A B C
4022311 CWT 3WC DGT SUPPRESS PUBLIC Y Y PIC 0893 Y SC2 CFW C NSCR 1 I $ CFDA N NSCR 1 A 24 FIXRING 5936245 CFBL N NSCR 1 A 5936245 LPIC 0893 Y
I thought the phone number(s) was embedded in the long text string? While I know everything about your data is clear to you, it is not clear to me at all... I am not clear on what your existing layout is nor what your final layout needs to be nor when our proposals should be applied. Unfortunately your example does not display in a manner that is easy to see which text belongs to which column. Instead of listing across, list down showing the value in each cell that way. For example...

A1: Value in Column A Row 1
B1: Value in Column B Row 1
C1: Value in Column C Row 1
D1: Result you want from the above

In the above listing, please make clear what your original data (before prepending) looks like. If you are overwriting existing data, then show us two listings like above... one for existing data before anything is done to it and a second one showing what you want the final result(s) to look like.
 
Last edited:
Upvote 0
Of course

[TABLE="width: 634"]
<tbody>[TR]
[TD]A1: Value in Column A Row 1[/TD]
[TD]5924124[/TD]
[/TR]
[TR]
[TD]B1: Value in Column B Row 1[/TD]
[TD]CWT 3WC DGT PIC 0893 Y SC2 CFW C NSCR 1 I 3153827146 PIC[/TD]
[/TR]
[TR]
[TD]C1: Value in Column C Row 1[/TD]
[TD]CFB N 3155936245 A 1 CBU CFD N 3155936245 A 1 CDU[/TD]
[/TR]
[TR]
[TD]D1: Result you want from the above[/TD]
[TD]5924124 CFW C NSCR 1 I 3827146 CFB N 3155936245 CFD N 3155936245[/TD]
[/TR]
</tbody>[/TABLE]

Thanks
 
Last edited:
Upvote 0
Of course

[TABLE="width: 634"]
<tbody>[TR]
[TD]A1: Value in Column A Row 1[/TD]
[TD]5924124[/TD]
[/TR]
[TR]
[TD]B1: Value in Column B Row 1[/TD]
[TD]CWT 3WC DGT PIC 0893 Y SC2 CFW C NSCR 1 I 3153827146 PIC[/TD]
[/TR]
[TR]
[TD]C1: Value in Column C Row 1[/TD]
[TD]CFB N 3155936245 A 1 CBU CFD N 3155936245 A 1 CDU[/TD]
[/TR]
[TR]
[TD]D1: Result you want from the above[/TD]
[TD]5924124 CFW C NSCR 1 I 3827146 CFB N 3155936245 CFD N 3155936245[/TD]
[/TR]
</tbody>[/TABLE]
This UDF should generate the values to populate Column D. Simply pass it the range for Columns A thru C. So, for the first row, the formula in Column D would be...

=CFs(A1:C1)

Here is the UDF code to install in your general module...
Code:
[table="width: 500"]
[tr]
	[td]Function CFs(Rng As Range) As String
  Dim X As Long, Z As Long, CF() As String
  CFs = Rng(1).Value
  CF = Split(" " & Application.Trim(Join(Application.Index(Range(Rng(2), Rng(Rng.Count)).Value, 1, 0))), " CF", , vbTextCompare)
  For X = 1 To UBound(CF)
    For Z = 1 To Len(CF(X))
      If Mid(CF(X), Z, 10) Like "##########" Then
        CFs = CFs & " CF" & Left(CF(X), Z + 9)
        Exit For
      End If
    Next
  Next
End Function[/td]
[/tr]
[/table]
 
Upvote 0
Rick, Thanks but it doesn't seem to be working. See my example below.

Column A = 5923391
Column B = CWT 3WC DGT PIC 0893 Y CFW C NSCR 1 I $ CFDA N NSCR 1 A 24 FIXRING 5936245
Column C = CFBL N NSCR 1 A 5936245 LPIC 0893 Y
Column D = 5923391 (formula view=CFs(A35:C35)

Thanks Again
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,238
Messages
6,170,939
Members
452,368
Latest member
jayp2104

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