increase cell by 1

  • Thread starter Thread starter Pa Maher
  • Start date Start date
P

Pa Maher

Can I create a cell (c3) on a sheet called "results" that increases by +1
each time a particular answer is selected on a quiz?
I already have a macro that gives feedback on why a particular answer is
correct or incorrect. I would like to have a register that would record how
many times a specific response was selected.
 
If you have a column of all possible answers (say, A, of worksheets Results), and all the answers
are unique, and you want the count in Column B, you could use

Dim myR As Long
Dim SelectedAnswer As Variant

SelectedAnswer = "Whatever the user selected" 'Need code to get a value into the variable

With Worksheets("Results")
myR = Application.Match(SelectedAnswer, .Column("A:A"),False)
.Cells(myR,2).Value = .Cells(myR,2)+1
End With
 
Thanks Bernie
I have not worked with DIM commands or variants, so your response is a bit
over my head.
I already have an open macro that knows the user has selected answer 1a to
question 1.
Is there some code that would go to worksheet "results" and and add 1 to a
specific cell, say cell "C2"? The following code is not working:
Worksheets("Results").Select ("C2")
.Cells("C2").Value = .Cells("C2") + 1
 
Try:

with Worksheets("Results").range("C2")
if isnumeric(.value) then
.value = .value + 1
end if
end with


..cells() takes two arguments--.cells(x,y) where x is the row (a number) and y is
the column (either a number or a letter).

I used .range() in the code I suggested.
 
Back
Top