vba: count non colored

montecarlo2012

Well-known Member
Joined
Jan 26, 2011
Messages
984
Office Version
  1. 2010
Platform
  1. Windows
Hello Mr. Excel Experts.
VBA Code:
Sub Basic_Programming()
Dim I As Integer, k As Integer
lastrow = Cells(Rows.Count, "B").End(xlUp).Row

I = 4  '---------------------------------------------------------------[start Cell B4]
If Cells(I, "B").Value = vbYellow Then '-----------------[count until yellow is found]
k = Cells(Rows.Count, "B").End(xlUp).Row
End If
For k = 4 To lastrow
        k = k + 1
Next k
Range("B1").Value = k
End Sub
This is a Basic Idea, I tried, and get wrong answer. I want to count only the cells without color,
I fill the color manually, no formatting, the values don't go by any pattern, and look for a code
1589673687794.png

I was expecting 5 as an answer, but I got 12, I am trying to keep AS SIMPLE OR BASIC AS POSSIBLE,
Thanks.
 
I really appreciate your invitation I have my workbook here:
Oh, you are using Google Sheets... I do not know anything about Google Sheets. I test all the code I post beforehand, so if the code I have given you doesn't work, I am guessing it has something to do with the difference between it and Excel (what this forum is designed to answer questions about).
 
Upvote 0

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Rick Rothstein the Great.
Thank you Sir for spent time in my post, I am glad I mentioned something that call your attention (google Sheets).
Differnces, really tricky.
1589731007816.png
really good subject.

That kind of question, is what I called the "Octopus question", :LOL: I don't know which of the 8 soft-limbed walk through out.
Thank you so much Rick Rothstein
 
Upvote 0

Forum statistics

Threads
1,217,371
Messages
6,136,171
Members
449,996
Latest member
duraichandra

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