Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Check if all values in a column is identical

Hi.
(VBA scripting in Excel 2003)

Case:
If all values in column A are identical, Then
No need to activate SUBTOTAL on the data.
Else
Activate SUBTOTALS.
End if

What would be a "slick" way of checking column A for changing values? The
smartes way I can think of is something like this

chkstr = Range("A2")
For i = 3 to LastRowOfData 'Data starts in row 2, row 1 contains heading
If Cells("A"&i) < chkstr Then
GoTo: InsertSubtotals
Next i

'Not even sure if it would work.....

Kind regards
Mr. Smith






  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Check if all values in a column is identical

Hello Mr. Smith
Here's a suggestion (dunno if its smarter!)
Amend with the relevant range reference:
'if identical values found exit the sub
If Evaluate("COUNTIF(A2:A76,A2)=COUNTA(A2:A76)") Then Exit Sub

HTH
Cordially
Pascal


"Mr. Smith" a écrit dans le message de news:
...
Hi.
(VBA scripting in Excel 2003)

Case:
If all values in column A are identical, Then
No need to activate SUBTOTAL on the data.
Else
Activate SUBTOTALS.
End if

What would be a "slick" way of checking column A for changing values? The
smartes way I can think of is something like this

chkstr = Range("A2")
For i = 3 to LastRowOfData 'Data starts in row 2, row 1 contains heading
If Cells("A"&i) < chkstr Then
GoTo: InsertSubtotals
Next i

'Not even sure if it would work.....

Kind regards
Mr. Smith








  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Check if all values in a column is identical

You could use this approach

If
ActiveSheet.Evaluate("SUMPRODUCT((A2:A20<"""")/COUNTIF(A2:A20,A2:A20&""""))")
1 Then

MsgBox "yes"
Else
MsgBox "no"
End If


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Mr. Smith" wrote in message
...
Hi.
(VBA scripting in Excel 2003)

Case:
If all values in column A are identical, Then
No need to activate SUBTOTAL on the data.
Else
Activate SUBTOTALS.
End if

What would be a "slick" way of checking column A for changing values? The
smartes way I can think of is something like this

chkstr = Range("A2")
For i = 3 to LastRowOfData 'Data starts in row 2, row 1 contains heading
If Cells("A"&i) < chkstr Then
GoTo: InsertSubtotals
Next i

'Not even sure if it would work.....

Kind regards
Mr. Smith








  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Check if all values in a column is identical

Nice twist Cordially!

Thanks!
Mr. Smith

"papou" wrote in message
...
Hello Mr. Smith
Here's a suggestion (dunno if its smarter!)
Amend with the relevant range reference:
'if identical values found exit the sub
If Evaluate("COUNTIF(A2:A76,A2)=COUNTA(A2:A76)") Then Exit Sub

HTH
Cordially
Pascal


"Mr. Smith" a écrit dans le message de news:
...
Hi.
(VBA scripting in Excel 2003)

Case:
If all values in column A are identical, Then
No need to activate SUBTOTAL on the data.
Else
Activate SUBTOTALS.
End if

What would be a "slick" way of checking column A for changing values? The
smartes way I can think of is something like this

chkstr = Range("A2")
For i = 3 to LastRowOfData 'Data starts in row 2, row 1 contains heading
If Cells("A"&i) < chkstr Then
GoTo: InsertSubtotals
Next i

'Not even sure if it would work.....

Kind regards
Mr. Smith










  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Check if all values in a column is identical

Just test if the MAX equals the MIN.
--
Gary''s Student - gsnu2007


"Mr. Smith" wrote:

Hi.
(VBA scripting in Excel 2003)

Case:
If all values in column A are identical, Then
No need to activate SUBTOTAL on the data.
Else
Activate SUBTOTALS.
End if

What would be a "slick" way of checking column A for changing values? The
smartes way I can think of is something like this

chkstr = Range("A2")
For i = 3 to LastRowOfData 'Data starts in row 2, row 1 contains heading
If Cells("A"&i) < chkstr Then
GoTo: InsertSubtotals
Next i

'Not even sure if it would work.....

Kind regards
Mr. Smith









  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Check if all values in a column is identical

Very elegant Gary's

Kind regards
Mr. Smith

"Gary''s Student" wrote in message
...
Just test if the MAX equals the MIN.
--
Gary''s Student - gsnu2007


"Mr. Smith" wrote:

Hi.
(VBA scripting in Excel 2003)

Case:
If all values in column A are identical, Then
No need to activate SUBTOTAL on the data.
Else
Activate SUBTOTALS.
End if

What would be a "slick" way of checking column A for changing values? The
smartes way I can think of is something like this

chkstr = Range("A2")
For i = 3 to LastRowOfData 'Data starts in row 2, row 1 contains heading
If Cells("A"&i) < chkstr Then
GoTo: InsertSubtotals
Next i

'Not even sure if it would work.....

Kind regards
Mr. Smith









Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
If value is true the check column for specific values MrPetreli Excel Discussion (Misc queries) 1 January 24th 12 11:50 PM
Merging files with nearly identical values in one column Allen Excel Discussion (Misc queries) 3 March 4th 09 05:09 PM
How to check for duplicate values within a column Andrew[_56_] Excel Programming 1 September 24th 07 03:53 PM
check value in cells against all values in a column Finn Excel Programming 3 March 29th 07 01:34 PM
Check for list of 3 values (alpha) in a column GeeSexAah[_2_] Excel Programming 0 November 22nd 04 12:08 PM


All times are GMT +1. The time now is 11:04 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"