I'm trying to use the following two codes I found to work as one task but only the first part works for me. What I'm trying to do is go through all sheets except the one named "WORKDONE" and use mid function to extract some digits from a specific cell to cell I6. That works ok. The problem comes from the second part where I want to check if cell I6 has the same value in all sheets except the first "WORKDONE". I know that the code below looks a bit messy but I'm not into vba that much. I'm just trying to make things easier. So your help is much appreciated. Thank you in advance for your kind attention and advice. I use excel 365.
VBA Code:
Sub match()
Dim myValue, f
Dim sht As Worksheet
Dim count&
Dim ws As Worksheet
For Each ws In Worksheets
If ws.Name <> "WORKDONE" Then
With ws
.Range("I6").FormulaR1C1 = _
"=MID(R[-2]C,8,6)"
End With
End If
Next ws
myValue = Sheets("1").Range("I6").Value
For Each sht In Sheets
If sht.Name <> "WORKDONE" Then
Set f = sht.Range("I6").Find(what:=myValue, Lookat:=xlPart)
If Not f Is Nothing Then
count = count + 1
Else
MsgBox sht.Name & " does not match"
Exit Sub
End If
End If
Next
If count = Sheets.count Then
MsgBox "allSame"
Else
MsgBox sht(Sheets.count).Name & " does not match"
End If
End Sub