VBA code to check values in row are the same

Rachey

New Member
Joined
Mar 3, 2015
Messages
5
Hi I need a code to check the values in row 7 are identical and pop up a message box if not. (to run on selection change)

Sounds simple but I cant seem to find anything that will help - use VBA quite a bit but usually find code on the internet and modify to do what I want. Im fine putting the message in I just cant find the code to check the values in the row are all the same.

Thanks
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Assuming we are indeed working with "values"...
I would just write a little function that tests to see if the Min and Max of the specified range are equivalent.

Code:
Sub Test()
    MsgBox SameVals(Range("7:7"))
End Sub

Function SameVals(ByRef Rng As Range) As Boolean
    With Application.WorksheetFunction
        SameVals = .Min(Rng) = .Max(Rng)
    End With
End Function
 
Upvote 0

Forum statistics

Threads
1,207,443
Messages
6,078,589
Members
446,350
Latest member
FrancieRech

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top