Hello Everyone,
Currently my main function is looping through the rows in the worksheet and making changes to different columns as it iterates through all of the data. In one column I have a telephone that is in a format I want changed:
(NPA) NXX-XXXX corrected to NPANXXXXXX
I.E. (408) 555-1212 to 4085551212
What I am trying to do is use another function that will chop up the telephone number and return the "corrected #" and then save the new value to the cell in the corresponding row. The problem I run into is when I compile the code I get
"Compile Error:
ByRef argument type mismatch"
Below is a sample of the code I am using
Function Prep_TestCCName()
' ******************** Detail for this Procedure ********************
'
Dim LastRow As Double ' Holds value for count of rows in WS
LastRow = ActiveSheet.UsedRange.Rows.Count ' Finds last 'row' in WS
For RowNumber = 2 To LastRow ' Start Loop
Call Prep_ReFormatCTN(CTNasNumber) ' See Procedure for details
Cells(RowNumber, 3).Value = CTNasNumber
Next RowNumber ' Move to next row in WS
End Function
Function Prep_ReFormatCTN(CTNasNumber As String) As Integer
' ******************** Detail for this Procedure ********************
If Len(Cells(RowNumber, 3).Value < 1) Then ' Cell is empty
CTNasNumber = Cells(RowNumber, 3).Value
Else ' Has a telephone #, format to NPANXXXXXX
CTNasNumber = Mid(Cells(RowNumber, 3), 2, 3) & _
Mid(Cells(RowNumber, 3), 7, 3) & _
Mid(Cells(RowNumber, 3), 11, 4)
End If
End Function
I have tried to modify my second function and change how the variable is being handled and the problem persists.
Function Prep_ReFormatCTN(CTNasNumber As String) As Integer
Function Prep_ReFormatCTN(CTNasNumber As String) As Double
Function Prep_ReFormatCTN(CTNasNumber As String) As String
' Or
Function Prep_ReFormatCTN(ByVal CTNasNumber As String) As Integer
Function Prep_ReFormatCTN(ByRef CTNasNumber As String) As Integer
I am sure it is something simple I am missing .. any idea's would be helpful.
Thank you everyone for your time,
Jason S
Bookmarks