![]() |
Adding Area Code To Phone Numbers
Greeting,
I am adding the area codes to a list of phone numbers. I have some code that does that. The problem is this list has a mix numbers. Some with area codes and some with out. I need a way to bypass those numbers with area codes and add the area codes to these without them. Some of the numbers also have an extension tacked on, so LEN won't work. Here is the code that I have: Private Sub CommandButton1_Click() Dim lastrow As Long Dim row_index As Long Dim col_index As Integer Dim text_value text_value = "(512) " For col_index = 10 To 14 lastrow = ActiveSheet.Cells(Rows.Count, _ col_index).End(xlUp).Row For row_index = 1 To lastrow If Cells(row_index, col_index).Value < "" Then Cells(row_index, col_index).Value = text_value & _ Cells(row_index, col_index).Value End If Next Next End Sub Anyone have any suggestions on how to exclude these cells which have an area code already? Any help would be appreciated. TIA -Minitman |
Adding Area Code To Phone Numbers
Hi
replace the line If Cells(row_index, col_index).Value < "" Then with the line If Cells(row_index, col_index).Value < "" and _ InStr(Cells(row_index, col_index).Value,")")=0 then -- Regards Frank Kabel Frankfurt, Germany "Minitman" schrieb im Newsbeitrag ... Greeting, I am adding the area codes to a list of phone numbers. I have some code that does that. The problem is this list has a mix numbers. Some with area codes and some with out. I need a way to bypass those numbers with area codes and add the area codes to these without them. Some of the numbers also have an extension tacked on, so LEN won't work. Here is the code that I have: Private Sub CommandButton1_Click() Dim lastrow As Long Dim row_index As Long Dim col_index As Integer Dim text_value text_value = "(512) " For col_index = 10 To 14 lastrow = ActiveSheet.Cells(Rows.Count, _ col_index).End(xlUp).Row For row_index = 1 To lastrow If Cells(row_index, col_index).Value < "" Then Cells(row_index, col_index).Value = text_value & _ Cells(row_index, col_index).Value End If Next Next End Sub Anyone have any suggestions on how to exclude these cells which have an area code already? Any help would be appreciated. TIA -Minitman |
Adding Area Code To Phone Numbers
Thanks Frank,
I'll give this a try ........ It works great. Thanks. -Minitman On Fri, 21 May 2004 18:13:09 +0200, "Frank Kabel" wrote: Hi replace the line If Cells(row_index, col_index).Value < "" Then with the line If Cells(row_index, col_index).Value < "" and _ InStr(Cells(row_index, col_index).Value,")")=0 then |
All times are GMT +1. The time now is 07:34 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com