ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Tallying Votes in Excel (https://www.excelbanter.com/excel-discussion-misc-queries/176081-tallying-votes-excel.html)

Noah Negrin

Tallying Votes in Excel
 
When conducting a vote and tallying results in excel, the two responses are
€˜YES and €˜NO. If 100 people are going to vote, and it requires 60 €˜YES
responses for the vote to pass, how can I program excel to count the €˜YES
votes and do something when it hits 60? If I could have it highlight the
cell below the voting results Green or something, that would be perfect.

Don Guillett

Tallying Votes in Excel
 
This macro will do it
Sub stopwhen()
mc = "f"
lr = Cells(Rows.Count, mc).End(xlUp).Row
For Each c In Range(Cells(2, mc), Cells(lr, mc))
If ucase(c) = "YES" Then myc = myc + 1
If myc = 60 Then
MsgBox c.Address & "=" & myc
c.Offset(1).Interior.ColorIndex = 36
Exit For
End If
Next
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Noah Negrin" <Noah
wrote in message
...
When conducting a vote and tallying results in excel, the two responses
are
€˜YES and €˜NO. If 100 people are going to vote, and it requires 60 €˜YES
responses for the vote to pass, how can I program excel to count the €˜YES
votes and do something when it hits 60? If I could have it highlight the
cell below the voting results Green or something, that would be perfect.



Noah Negrin[_2_]

Tallying Votes in Excel
 
Don,

Unfortunately I am not very familiar with Macros. Is there a formula I
could input into a cell to count up the YES votes? Or could you explain to
me in as basic terms as possible how to input that Macro?

Thanks very much!

"Don Guillett" wrote:

This macro will do it
Sub stopwhen()
mc = "f"
lr = Cells(Rows.Count, mc).End(xlUp).Row
For Each c In Range(Cells(2, mc), Cells(lr, mc))
If ucase(c) = "YES" Then myc = myc + 1
If myc = 60 Then
MsgBox c.Address & "=" & myc
c.Offset(1).Interior.ColorIndex = 36
Exit For
End If
Next
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Noah Negrin" <Noah
wrote in message
...
When conducting a vote and tallying results in excel, the two responses
are
€˜YES and €˜NO. If 100 people are going to vote, and it requires 60 €˜YES
responses for the vote to pass, how can I program excel to count the €˜YES
votes and do something when it hits 60? If I could have it highlight the
cell below the voting results Green or something, that would be perfect.




Don Guillett

Tallying Votes in Excel
 
You could do this with formula(s) but it would create overhead. The macro
approach is better.

If you're new to macros, you may want to read David McRitchie's intro
at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Noah Negrin" wrote in message
...
Don,

Unfortunately I am not very familiar with Macros. Is there a formula I
could input into a cell to count up the YES votes? Or could you explain
to
me in as basic terms as possible how to input that Macro?

Thanks very much!

"Don Guillett" wrote:

This macro will do it
Sub stopwhen()
mc = "f"
lr = Cells(Rows.Count, mc).End(xlUp).Row
For Each c In Range(Cells(2, mc), Cells(lr, mc))
If ucase(c) = "YES" Then myc = myc + 1
If myc = 60 Then
MsgBox c.Address & "=" & myc
c.Offset(1).Interior.ColorIndex = 36
Exit For
End If
Next
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Noah Negrin" <Noah
wrote in message
...
When conducting a vote and tallying results in excel, the two responses
are
€˜YES and €˜NO. If 100 people are going to vote, and it requires 60
€˜YES
responses for the vote to pass, how can I program excel to count the
€˜YES
votes and do something when it hits 60? If I could have it highlight
the
cell below the voting results Green or something, that would be
perfect.





Don Guillett

Tallying Votes in Excel
 
Formula in helper column
=IF(COUNTIF($F$2:$F8,"y")6,"",COUNTIF($F$2:$F8,"y "))
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Noah Negrin" wrote in message
...
Don,

Unfortunately I am not very familiar with Macros. Is there a formula I
could input into a cell to count up the YES votes? Or could you explain
to
me in as basic terms as possible how to input that Macro?

Thanks very much!

"Don Guillett" wrote:

This macro will do it
Sub stopwhen()
mc = "f"
lr = Cells(Rows.Count, mc).End(xlUp).Row
For Each c In Range(Cells(2, mc), Cells(lr, mc))
If ucase(c) = "YES" Then myc = myc + 1
If myc = 60 Then
MsgBox c.Address & "=" & myc
c.Offset(1).Interior.ColorIndex = 36
Exit For
End If
Next
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Noah Negrin" <Noah
wrote in message
...
When conducting a vote and tallying results in excel, the two responses
are
€˜YES and €˜NO. If 100 people are going to vote, and it requires 60
€˜YES
responses for the vote to pass, how can I program excel to count the
€˜YES
votes and do something when it hits 60? If I could have it highlight
the
cell below the voting results Green or something, that would be
perfect.





Don Guillett

Tallying Votes in Excel
 
I should give more info. If data in f2 down, put this formula in g2 and copy
down.
=IF(COUNTIF($F$2:$F2,"y")6,"",COUNTIF($F$2:$F2,"y "))

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Don Guillett" wrote in message
...
Formula in helper column
=IF(COUNTIF($F$2:$F8,"y")6,"",COUNTIF($F$2:$F8,"y "))
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Noah Negrin" wrote in message
...
Don,

Unfortunately I am not very familiar with Macros. Is there a formula I
could input into a cell to count up the YES votes? Or could you explain
to
me in as basic terms as possible how to input that Macro?

Thanks very much!

"Don Guillett" wrote:

This macro will do it
Sub stopwhen()
mc = "f"
lr = Cells(Rows.Count, mc).End(xlUp).Row
For Each c In Range(Cells(2, mc), Cells(lr, mc))
If ucase(c) = "YES" Then myc = myc + 1
If myc = 60 Then
MsgBox c.Address & "=" & myc
c.Offset(1).Interior.ColorIndex = 36
Exit For
End If
Next
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Noah Negrin" <Noah
wrote in message
...
When conducting a vote and tallying results in excel, the two
responses
are
€˜YES and €˜NO. If 100 people are going to vote, and it requires 60
€˜YES
responses for the vote to pass, how can I program excel to count the
€˜YES
votes and do something when it hits 60? If I could have it highlight
the
cell below the voting results Green or something, that would be
perfect.





Brad

Tallying Votes in Excel
 
In cell c1

=COUNTIF(B1:B100,"Yes")

In cell c2

=if(C1=60,do condition a,do nothing)


"Noah Negrin"
wrote:

When conducting a vote and tallying results in excel, the two responses are
€˜YES and €˜NO. If 100 people are going to vote, and it requires 60 €˜YES
responses for the vote to pass, how can I program excel to count the €˜YES
votes and do something when it hits 60? If I could have it highlight the
cell below the voting results Green or something, that would be perfect.



All times are GMT +1. The time now is 10:09 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com