FranktheBank
Member
I have the below Code, it simply is supposed to compare 'ThisWorkbook' Cells 2B, 2G and 2H in a loop with "IT_Expenditure" Worksheet "IT_Expenditure_Wks" Cells 2B, 2P and 2Q then 3B, 3P and 3Q etc.
When it gets to: If Worksheets("IT_ITGov_Expenses").Cells(lngI, 2) = Worksheets("IT_Expenditure_Wks").Cells(lng2, 2) I get the error:Runtime Error:13 Type mismatch.
I've replaced the"B", "G","H", "P" & "Q" with their corresponding number (2,7,8,16 & 17) and I get the same Error. I'm missing something simple can someone point it out?? Thanks
Post Moved by Mod
When it gets to: If Worksheets("IT_ITGov_Expenses").Cells(lngI, 2) = Worksheets("IT_Expenditure_Wks").Cells(lng2, 2) I get the error:Runtime Error:13 Type mismatch.
I've replaced the"B", "G","H", "P" & "Q" with their corresponding number (2,7,8,16 & 17) and I get the same Error. I'm missing something simple can someone point it out?? Thanks
Code:
Sub Definitions()
Application.ScreenUpdating = True
Dim Vendor_Code As String
Dim Vendor_Name As String
Dim Account As String
Dim IT_Expenditure As Workbook
Dim IT_Expenditure_Wks As Worksheet
Dim IT_ITGov As Workbook
Dim IT_ITGov_Expense As Worksheet
'
Set IT_ITGov = ThisWorkbook
Set IT_ITGov_Expenses = IT_ITGov.Sheets("IT_ITGov_Expenses")
Set IT_Expenditure = Workbooks.Open("G:\Planning\Branches\ITT\2015-16\IT Expenditure\IT Expenditure Workbook_20150817.xls")
Set IT_Expenditure_Wks = IT_Expenditure.Sheets("Workbook")
ThisWorkbook.Activate
Dim lngI As Long
Dim lng2 As Long
For lngI = 2 To Worksheets("IT_ITGov_Expenses").UsedRange.Rows.Count Step 1
With Cells(lngI, "B")
For lng2 = 2 To IT_Expenditure_Wks.UsedRange.Rows.Count Step 1
With Worksheets("IT_ITGov_Expenses").Cells(lngI, "B")
If Worksheets(IT_ITGov_Expenses).Cells(lngI, 2) = Worksheets("IT_Expenditure_Wks").Cells(lng2, 2) Then
If Worksheets(IT_ITGov_Expenses).Cells(lngI, 7) = Worksheets("IT_Expenditure_Wks").Cells(lng2, 16) Then
If Worksheets(IT_ITGov_Expenses).Cells(lngI, 8) = Worksheets("IT_Expenditure_Wks").Cells(lng2, 17) Then
Worksheets(IT_ITGov_Expenses).Cells(lngI, "N") = Worksheets("IT_Expenditure_Wks").Cells(lng2, "S")
End If
End If
End If
End With
Next
End With
Next
End Sub
Post Moved by Mod
Last edited by a moderator: