LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Junior Member
 
Posts: 18
Default Runtime error 13 : type mismatch

I am receiving the runtime error 13 message on
this line of code

If UCase(CUCM.Cells(CUCMSourceRow, 4)) = UCase(ALIR.Cells(MainLoop, 15)) And UCase(CUCM.Cells(CUCMSourceRow, 2)) = UCase(ALIR.Cells(MainLoop, 14)) And (UCase(CUCM.Cells(CUCMSourceRow, 1)) = UCase(ALIR.Cells(MainLoop, 11)) Or UCase(CUCM.Cells(CUCMSourceRow, 1)) = UCase(ALIR.Cells(MainLoop, 12))) Then


the entire code this is from is

Sub Button1_Click()
Dim LastRow As Long
Dim LastResultRow As Long
Dim DestinationRow As Long
Dim ALIRSourceRow As Long
Dim CUCMSourceRow As Long
Dim MainLoop As Long

LastRow = ALIR.UsedRange.Rows.Count
DestinationRow = 3
ALIRSourceRow = 2
CUCMSourceRow = 2
MatchType = 0
LastResultRow = Results.UsedRange.Rows.Count
Results.Range(Cells(3, 1), Cells(LastRow, 9)).ClearContents
Results.Range(Cells(3, 1), Cells(LastRow, 9)).Interior.ColorIndex = 0

Do While CUCM.Cells(CUCMSourceRow, 3) < ""
For MainLoop = 2 To LastRow
'If match all then MatchType = 1
If CUCM.Cells(CUCMSourceRow, 5) = Right(ALIR.Cells(MainLoop, 32), 10) Then
MatchType = 3
ALIRSourceRow = MainLoop
'If UCase(CUCM.Cells(CUCMSourceRow, 4)) = UCase(ALIR.Cells(MainLoop, 15)) Then
'If UCase(CUCM.Cells(CUCMSourceRow, 2)) = UCase(ALIR.Cells(MainLoop, 14)) Then
'If UCase(CUCM.Cells(CUCMSourceRow, 1)) = UCase(ALIR.Cells(MainLoop, 11)) Or UCase(CUCM.Cells(CUCMSourceRow, 1)) = UCase(ALIR.Cells(MainLoop, 12)) Then
If UCase(CUCM.Cells(CUCMSourceRow, 4)) = UCase(ALIR.Cells(MainLoop, 15)) And UCase(CUCM.Cells(CUCMSourceRow, 2)) = UCase(ALIR.Cells(MainLoop, 14)) And (UCase(CUCM.Cells(CUCMSourceRow, 1)) = UCase(ALIR.Cells(MainLoop, 11)) Or UCase(CUCM.Cells(CUCMSourceRow, 1)) = UCase(ALIR.Cells(MainLoop, 12))) Then
MatchType = 1
Call WriteRow(MainLoop, CUCMSourceRow, DestinationRow, MatchType)
DestinationRow = DestinationRow + 1
Exit For
Else
Call WriteRow(MainLoop, CUCMSourceRow, DestinationRow, MatchType)
DestinationRow = DestinationRow + 1
Exit For
End If
Else
'If UCase(CUCM.Cells(CUCMSourceRow, 4)) = UCase(ALIR.Cells(MainLoop, 15)) Then
'If UCase(CUCM.Cells(CUCMSourceRow, 2)) = UCase(ALIR.Cells(MainLoop, 14)) Then
'If UCase(CUCM.Cells(CUCMSourceRow, 1)) = UCase(ALIR.Cells(MainLoop, 11)) Or UCase(CUCM.Cells(CUCMSourceRow, 1)) = UCase(ALIR.Cells(MainLoop, 12)) Then
If UCase(CUCM.Cells(CUCMSourceRow, 4)) = UCase(ALIR.Cells(MainLoop, 15)) And UCase(CUCM.Cells(CUCMSourceRow, 2)) = UCase(ALIR.Cells(MainLoop, 14)) And (UCase(CUCM.Cells(CUCMSourceRow, 1)) = UCase(ALIR.Cells(MainLoop, 11)) Or UCase(CUCM.Cells(CUCMSourceRow, 1)) = UCase(ALIR.Cells(MainLoop, 12))) Then
MatchType = 2
Call WriteRow(MainLoop, CUCMSourceRow, DestinationRow, MatchType)
DestinationRow = DestinationRow + 1
Exit For
End If
End If
Next MainLoop
CUCMSourceRow = CUCMSourceRow + 1

MatchType = 5
Loop

End Sub


Function WriteRow(ByVal ALIRSourceRow As Long, _
ByVal CUCMSourceRow As Long, _
ByVal DestinationRow As Long, _
ByVal MatchType As Integer)
Dim ALIRSourceCol(1 To 2) As Integer
Dim CUCMSourceCol(1 To 5) As Integer
Dim LoopCount As Integer
Dim GREEN As Integer
Dim YELLOW As Integer
Dim ORANGE As Integer
Dim BLUE As Integer

ALIRSourceCol(1) = 21 'Principal Country Location
ALIRSourceCol(2) = 28 'Unique Key
CUCMSourceCol(1) = 1 'First Name
CUCMSourceCol(2) = 2 'Last Name
CUCMSourceCol(3) = 3 'User ID
CUCMSourceCol(4) = 4 'Department


GREEN = 43
YELLOW = 6
ORANGE = 45
BLUE = 23


For LoopCount = 1 To 4
CUCM.Cells(CUCMSourceRow, CUCMSourceCol(LoopCount)).Copy
Results.Cells(DestinationRow, LoopCount).PasteSpecial (xlPasteValues)
Application.CutCopyMode = False
Next LoopCount

For LoopCount = 1 To 2
ALIR.Cells(ALIRSourceRow, ALIRSourceCol(LoopCount)).Copy
Results.Cells(DestinationRow, (LoopCount + 4)).PasteSpecial (xlPasteValues)
Application.CutCopyMode = False
Next LoopCount

Results.Cells(DestinationRow, 7).Value = MatchType
Results.Cells(DestinationRow, 8).Value = CUCMSourceRow
Results.Cells(DestinationRow, 9).Value = ALIRSourceRow

Select Case MatchType
Case 0
Case 1
For LoopCount = 1 To 7
Results.Cells(DestinationRow, LoopCount).Interior.ColorIndex = GREEN
Next LoopCount
Case 2
For LoopCount = 1 To 7
Results.Cells(DestinationRow, LoopCount).Interior.ColorIndex = YELLOW
Next LoopCount
Case 3
For LoopCount = 1 To 7
Results.Cells(DestinationRow, LoopCount).Interior.ColorIndex = ORANGE
Next LoopCount
Case 4
For LoopCount = 1 To 7
Results.Cells(DestinationRow, LoopCount).Interior.ColorIndex = BLUE
Next LoopCount
End Select
End Function


I cannot see why I am getting this error can anyone please help me?
 
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
Runtime Error 13 Type Mismatch Arturo Excel Programming 1 January 31st 07 03:24 PM
Runtime Error Type 13 Mismatch Linking to specific cells in pivot table Excel Programming 5 May 31st 06 05:31 PM
Runtime Error '13': Type mismatch Linking to specific cells in pivot table Excel Programming 2 May 18th 05 07:34 PM
Runtime error 13 type mismatch ? JoeH[_15_] Excel Programming 1 September 25th 04 06:00 PM
Runtime error 13 type mismatch ? JoeH[_14_] Excel Programming 1 September 25th 04 04:57 PM


All times are GMT +1. The time now is 10:20 PM.

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"