ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Countif Code (https://www.excelbanter.com/excel-programming/444597-countif-code.html)

Steve[_4_]

Countif Code
 
Hi everyone,

I am trying to promt the user with an input box "What column to
count", then use that column to count the number of "Y"s in the
column, and return the number in a message box. Here's what I have so
far:

Sub Count_Yes()

Dim Count_Col As Range

Set Count_Col = Application.InputBox(prompt:= _
"Select Any Cell in Column to Count", Type:=8)
If Count_Col Is Nothing Then
Exit Sub
End If

'Count Function
'Message Box

End Sub

Thanks for any help!

Gord Dibben[_2_]

Countif Code
 
MsgBox WorksheetFunction.CountIf(Count_Col.EntireColumn, "Y")


Gord Dibben MS Excel MVP

On Tue, 17 May 2011 16:32:50 -0700 (PDT), Steve
wrote:

Hi everyone,

I am trying to promt the user with an input box "What column to
count", then use that column to count the number of "Y"s in the
column, and return the number in a message box. Here's what I have so
far:

Sub Count_Yes()

Dim Count_Col As Range

Set Count_Col = Application.InputBox(prompt:= _
"Select Any Cell in Column to Count", Type:=8)
If Count_Col Is Nothing Then
Exit Sub
End If

'Count Function
'Message Box

End Sub

Thanks for any help!


muddan madhu

Countif Code
 
Sub Count_Yes()
Dim R As Integer
On Error Resume Next
With Application
R = .InputBox("Select Any Cell in Column to Count",
Type:=8).Column
If R < 0 Then MsgBox .WorksheetFunction.CountIf(Columns(R), "Y")
End With
End Sub


On May 18, 4:32*am, Steve wrote:
Hi everyone,

I am trying to promt the user with an input box "What column to
count", then use that column to count the number of "Y"s in the
column, and return the number in a message box. *Here's what I have so
far:

Sub Count_Yes()

Dim Count_Col As Range

* * Set Count_Col = Application.InputBox(prompt:= _
* * * * * * "Select Any Cell in Column to Count", Type:=8)
* * * * If Count_Col Is Nothing Then
* * * * * * Exit Sub
* * * * End If

* * * * 'Count Function
* * * * 'Message Box

End Sub

Thanks for any help!



Steve[_4_]

Countif Code
 
Thanks Gord!

On May 17, 7:51*pm, Gord Dibben wrote:
MsgBox WorksheetFunction.CountIf(Count_Col.EntireColumn, "Y")

Gord Dibben * * MS Excel MVP

On Tue, 17 May 2011 16:32:50 -0700 (PDT), Steve
wrote:



Hi everyone,


I am trying to promt the user with an input box "What column to
count", then use that column to count the number of "Y"s in the
column, and return the number in a message box. *Here's what I have so
far:


Sub Count_Yes()


Dim Count_Col As Range


* *Set Count_Col = Application.InputBox(prompt:= _
* * * * * *"Select Any Cell in Column to Count", Type:=8)
* * * *If Count_Col Is Nothing Then
* * * * * *Exit Sub
* * * *End If


* * * *'Count Function
* * * *'Message Box


End Sub


Thanks for any help!- Hide quoted text -


- Show quoted text -




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

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