Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 273
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default 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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 273
Default 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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding area codes only to phone numbers missing an area code RC Excel Discussion (Misc queries) 5 May 3rd 23 05:06 PM
Deleting the area code on excel spread sheet phone numbers?? Ben Excel Discussion (Misc queries) 4 October 3rd 07 01:34 PM
Phone with/without area code format barnabas Excel Worksheet Functions 2 September 4th 07 06:15 PM
adding a phone area code that is not there Kelly Excel Discussion (Misc queries) 4 December 13th 06 12:15 AM
How do I add an area code to a list of phone numbers in Excel? PPuser Excel Worksheet Functions 2 April 5th 05 08:35 PM


All times are GMT +1. The time now is 11:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"