Increasing number depending on input

N

n_sabra64

Bear with me I am an Excel novice,

I am trying to figure out what formula I need to increase a number in a
certain cell, in response to an input from another cell.

Example:
In Cell C2, If B2 equals 1, I need the number in C2 to increase by 1
......but I also need the number in C2 not to change if another number is
entered.

Basically B2 will increase the numbers in other cells depending on what is
entered.


This is for a survey type form, and I need to track how many 1's, 2's, 3's,
etc. are entered.
 
S

Sheeloo

What you want can be done using COUNTIF formula

=COUNTIF(B1:B100,1) will give you the count of cells equal to 1
adjust 100 to last row in your data

What you can do is enter 1,2 ... in, say, cell D1, D2,...
then in C1 enter
=COUNTIF(B$1:B$100,D1) and copy to C2, C3 etc.
 
N

n_sabra64

Sheeloo said:
What you want can be done using COUNTIF formula

=COUNTIF(B1:B100,1) will give you the count of cells equal to 1
adjust 100 to last row in your data

What you can do is enter 1,2 ... in, say, cell D1, D2,...
then in C1 enter
=COUNTIF(B$1:B$100,D1) and copy to C2, C3 etc.
 
N

n_sabra64

Unfortunately I was not clear enough, but I also need the number to not
change in C2 if another number is put in. In other words, D2 will count how
many times 2 is put in B2, and E2 will count how many times 3 is put in B2,
F2......
In other words B2 will change, but I need the tracking Cells to only
increment when their corresponding number is entered and not to reset. I know
I am not explaining this clearly enough, but I appreciate your help.
 
M

Mike H

Hi,

You need a macro for that. Right click your sheet tab, view code and paste
this in.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
If Target.Address = "$B$2" And IsNumeric(Target) Then
Select Case Target.Value
Case Is = 2
Range("D2").Value = Range("D2").Value + 1
Case Is = 3
Range("E2").Value = Range("E2").Value + 1
End Select
End If
End Sub

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top