clarksonneo
01-15-2011, 05:37 PM
Hi,
I hope that:
When I type a word in column B, the cell in column D on the same row will be entered a formula that can count the number of that word in column B.
The following picture is my expected result.
Eg, when a typed "A" in cell B5, cell D5 will be entered =COUNTIF(B:B,B5)
Eg, if I haven't type anything in cell B10, cell D10 is empty.
Could you please amend my code so that my marco can produce the expected result?
If possible, please use select case, as I want to learn it.
Sub CountWhenType()
Dim i As Integer
Dim a As Range
a = Cells(i, 2).Value
Select Case a
Case ""
Cells(i, 4).Value = ""
Case Else
Cells(i, 4).Formula = "COUNTIF(C:C, B & i )"
End Select
End Sub
Thanks
I hope that:
When I type a word in column B, the cell in column D on the same row will be entered a formula that can count the number of that word in column B.
The following picture is my expected result.
Eg, when a typed "A" in cell B5, cell D5 will be entered =COUNTIF(B:B,B5)
Eg, if I haven't type anything in cell B10, cell D10 is empty.
Could you please amend my code so that my marco can produce the expected result?
If possible, please use select case, as I want to learn it.
Sub CountWhenType()
Dim i As Integer
Dim a As Range
a = Cells(i, 2).Value
Select Case a
Case ""
Cells(i, 4).Value = ""
Case Else
Cells(i, 4).Formula = "COUNTIF(C:C, B & i )"
End Select
End Sub
Thanks