M
Minitman
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
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