Eliminate all cells that don't contain a telephone number

skyport

Active Member
Joined
Aug 3, 2014
Messages
374
I need to be able to eliminate all cells in a column that don't contain a telephone number in the cell. Note: when a telephone number would be in a cell,it would be the only data within that cell. Does anyone have an idea on how this can be done?
 
...because of the way each treats the data in the end result.
Are you referring to where our codes output the results to? If so, my code can be modified easily enough to output the results to a different column. Assuming your data is in Column A and the results are to go to Column B...
Code:
Sub LeaveOnlyPhoneNumbers()
  Dim Addr As String
  Addr = "A1:A" & Cells(Rows.Count, "A").End(xlUp).Row
  Range("B1").Range(Addr) = Evaluate(Replace("IF(LEFT(@)=""("",IF(@="""","""",@),NA())", "@", Addr))
  On Error GoTo NoPhoneNumbers
  Columns("B").SpecialCells(xlConstants, xlErrors).Delete xlShiftUp
NoPhoneNumbers:
End Sub
 
Upvote 0

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Rick,

Thanks for the extra mile on this. It is nice to have it both ways because each serve a purpose in a different way under different circumstances. There will be times when each version will be helpful. Thanks again for the great solutions.
 
Upvote 0
To Both Rick and Hiker 95

Both programs work absolutely perfect. There is even a purpose for using them both because of the way each treats the data in the end result.

Thank you both so very much. This is what makes the Excel community so great. It was great to see you both again here on the forum and I also thank both of you for all the great solutions you have contributed over the past year.

If anyone else started a solution and you want me to test it out, I will be happy to give feed back although the problem has been resolved.

skyport

Thanks for the feedback.

You are very welcome. Glad we could help.

And, come back anytime.
 
Upvote 0

Forum statistics

Threads
1,214,785
Messages
6,121,543
Members
449,038
Latest member
Guest1337

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