kelly mort
Well-known Member
- Joined
- Apr 10, 2017
- Messages
- 2,157
- Office Version
-
- 2016
- Platform
-
- Windows
Hello,
I need a way to check if same items appear in a column for multiple sheets.
I have a 5 sheets and I want to check if a column say Y, has the same items.
Let say if *mangoes" appear in that column on all sheets, there is a match else there is no match.
I came across this code written by @Joe4
The only issue I have with this is that it only checks for a single sheet.
www.mrexcel.com
I am thing of looping the sheets but with my current state of thinking, I will be resetting the Boolean each time which will trick me into thinking I am doing the right thing.
How do I get it done properly?
I need a way to check if same items appear in a column for multiple sheets.
I have a 5 sheets and I want to check if a column say Y, has the same items.
Let say if *mangoes" appear in that column on all sheets, there is a match else there is no match.
I came across this code written by @Joe4
The only issue I have with this is that it only checks for a single sheet.

Looking for VBA to check if all data in a column is the same (text)
Looking for VBA to check if all data in a column is the same (text) - For example - if I did it manually -top row cell 1 would contain" '=IF(AND(B1=B2,B2=B3,B3=B4,B4=B5,B5=B6,B6=B7,B7=B8,B8=B9),TRUE,FALSE) But ideally I need this to just loop thru and check that all cols contain same text -...
Code:
Sub Check()
Dim myRange As Range
Dim myValue
Dim allSame As Boolean
' Set column to check
Set myRange = Range("C:C")
' Get first value from myRange
myValue = myRange(1, 1).Value
allSame = (WorksheetFunction.CountA(myRange) = WorksheetFunction.CountIf(myRange, myValue))
' Return whether or not they are all the same (TRUE/FALSE)
MsgBox allSame
End Sub
I am thing of looping the sheets but with my current state of thinking, I will be resetting the Boolean each time which will trick me into thinking I am doing the right thing.
How do I get it done properly?