Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Adding area codes only to phone numbers missing an area code | Excel Discussion (Misc queries) | |||
Deleting the area code on excel spread sheet phone numbers?? | Excel Discussion (Misc queries) | |||
Phone with/without area code format | Excel Worksheet Functions | |||
adding a phone area code that is not there | Excel Discussion (Misc queries) | |||
How do I add an area code to a list of phone numbers in Excel? | Excel Worksheet Functions |