PDA

View Full Version : [SOLVED] Dcount Last Character In Column



fb7894
06-09-2008, 07:49 PM
Is it possible to do a DCount on a the last character in a column?

Example: Suppose column A has the following data...
RGR
RARG
AGGR
GRAGA

I'd like to count the number of rows where the last character = R (The answer would be 2 in this example).

Ago
06-09-2008, 11:29 PM
Sub Find_R()
Dim mycell
For Each mycell In Range("G1", "G500") '<-- change to suit
If Right(mycell.Value, 1) = "R" Then
answer = answer + 1
End If
Next mycell
MsgBox answer
End Sub

Bob Phillips
06-10-2008, 01:15 AM
=SUMPRODUCT(--(RIGHT(A1:A4,1)="R"))

Bob Phillips
06-10-2008, 01:16 AM
Even better


=COUNTIF(A1:A4,"*R")