Check values within selection

mucah!t

Well-known Member
Joined
Jun 27, 2009
Messages
593
Hi all,

Lets say one selects range A3:F6.
Is it possible via VBA to check if the values in range C3:C6 are equal.
The selection is always a range between A and F but the selected rows differ.

All help welcome
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
yes it's going to be possible, but we need a clearer explaination of what you want...

Wouldn't it be B3:E6 That is between A3:F6 ?

What logic determines which area to check?
 
Upvote 0
Is it text or numeric data?

If numeric, then this ought to work
Code:
Sub seltest
  if worksheetfunction.average(selection) = worksheetfunction.max(selection) then
    msgbox "All values in selection are equal"
  end if
end sub
 
Upvote 0
Hello Weaver,
I already mentioned it in my first post.
all values in column C, that are selected, need to be the same
 
Upvote 0
Hello Weaver,
I already mentioned it in my first post.
all values in column C, that are selected, need to be the same

It was me who asked the question, Not Weaver..

And didn't mean to offend, but your question did not seem that clear to me. But I think I get it now...

Try
Code:
Sub test()
With Intersect(Selection, Range("C:C"))
    If Application.CountIf(.Cells, .Cells(1, 1)) = .Cells.Count Then
        MsgBox "All values in selection are equal"
    Else
        MsgBox "All values in selection are NOT equal"
    End If
End With
End Sub
 
Upvote 0
Thanks for helping Weaver.
The data in column C are date's.
But your codes checks the whole selected range, while I need it to only check a small part of the whole selection [those selected values that are in column C]
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,729
Members
452,939
Latest member
WCrawford

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