Below is the code I have so far. I am trying to do the following:
Compare the “ICT number” to the name of worksheet and if that worksheet name contains the ICT number, even if it is mixed in with other string values, then i want to look at a certain cell in that worksheet and compare the value in that cell with a cell in my checklist worksheet.
If those values are the same, then i want to have a message come up in a corresponding cell on that row saying that the two sources reconcile.
I then want this to loop for all of the rows in the checklist worksheet and all of the worksheets in the workbook.
Dim ICT_Number As Range
Dim statmentdata As Range
Dim checklistdata As Range
Dim Worksheet As Variant
Dim reconcile As Range
For Each cell In Range("d6:d236")
Set ICT_Number = ActiveCell
Set statementdata = Worksheets("m0017 v p0903").Range("H2016")
Set checklistdata = ActiveCell.Offset(0, 5)
Set currsheet = Worksheets("m0017 v p0903")
Set reconcile = ActiveCell.Offset(0, 11)
If InStr(1, cell, ICT_Number, 1) Then
If statmentdata = checklistdata Then
reconclie.Value = "this line reconiles"
Else
reconcile.Value = "this line does not reconclie"
End If
Next cell
End Sub
You have several issues in your code:
Don’t use protected (or ambiguous) names for your variables.
Please DON’T DO:
Better do:
Use
Setwhen assigning an objectThis WON’T work:
Instead, do:
What your code could look like
Before anything else
Please have a look at a VBA Tutorial to learn the syntax: VBA: Basic Syntax and Examples Tutorial