Add One to YES or NO

NutriMiah

New Member
Joined
Jan 11, 2018
Messages
8
Hello All,

I am trying to write a simple code to look at a value then find that value in a row of values and if another cell says YES then add one to the YES column and if not then add to the no column. The problem keeps giving me an error and I can't figure it out.

Attached I have put an example of the data and here is my code.

Sub Confidence()
With Sheets("Confidence")

If .Range("k90") = "" Then Exit Sub
If .Range("k91") = "" Then Exit Sub
Set Rng = Sheets("Confidence").Rows(1).Find(Range("k90"), , xlValues, xlWhole).Offset(2)

If .Range("k91") = "Yes" Then Rng.Value = Rng.Value + 1 Else Rng.Offset(, 1) = Rng.Offset(, 1) + 1

End With
End Sub


Sheet Confidence:
Row 1 looks like:
[FONT=&quot]A1: 5.30 b1: blank c1: 5.25 d1: blank e1: 5.2 (and so on down to 0)
Row 2 looks like:
A2: YES B2: NO C2: YES D2: NO and so on
Row 3 looks like:
A3: 4 B3: 1 C3: 7 (they all have numbers under each yes or no)

I can't attach a file.
[/FONT]
 
Last edited by a moderator:

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Hi

the code refers to cells, k90, and k91 - can you clarify what these cells (and any important adjacent ones) contain?
 
Upvote 0
K90 will have an equation output that will be a number that will match one of the numbers in row 1, eg 5.2 or 2.85
K91 will be an equation output that will be either YES or NO.
Hope this make sense.
 
Upvote 0
Ok, thanks for clarifying, and I now have the code running (and adding +1 into the values in row 3), with no errors.

What error message are you getting?
 
Upvote 0
Hi will have a look and let you know when I’m back at home on the 22nd
 
Upvote 0
Run time error '91'
Object variable or With block variable not set
Did you change your code from your first post?
If so, please post it so that we can see what you currently have.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,183
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top