PDA

View Full Version : Making an Auxiliary Table For Counting Colored Cells



harber95
08-15-2015, 10:15 AM
14178

In this file, I need to creat a table (appears in cells C8 to D35). C column is the number of cycles and D column is supposed to count the number of cells that turned blue. Note: lines 2 and 3 represent x and y values, therefor, only the blue cells on line 2 need to be counted when turned blue. Instead, I didn't get the count correctly, making every line be 0.
Thanks for the help (All code in module1)

p45cal
08-16-2015, 05:15 AM
see attached

SamT
08-16-2015, 06:19 AM
This is asking IF Cells(i,j) is a boolean value

If Cells(i, j) = Cells.Interior.Pattern = xlSolid And Cells.Interior.Color = vbBlue Then
In other words, given "X = A = B." IF A <> B, then X is set False. I see that you have used "X = A = B" in many places.
I think that line should be

If Cells(i, j).Interior.Pattern = xlSolid And Cells(i, j).Interior.Color = vbBlue Then



This is just wrong

Cells(i, j).Interior.Color.vbBlue.Count = T
A Range has an Interior Property that returns an Interior Object, that, in turn, has a Color Property that can be set to a "color," (ie. vbBlue.) The Interior's Color Property does not return an Object that has a vbBlue Property that returns a vbBlue Object that has a Count Property. vbBlue is a numerical Constant, HEX HFF0000. or Decimal 1611680.


Function CountCcolor is in two places but is not called anywhere.


Unintiated Variables occur in multiple places.

If Height = s Then 's is uninitiated, therefore s = "". An uninitiated numerical variable = 0.
MsgBox "Please use a natural number that is smaller than 250"
Should be

If Not IsNumeric(Height) Then
MsgBox "Please use a natural number that is smaller than 250"


It is never wise to reuse words in your code. For example you have a TextBox "Height" and in it's Change Event Sub, you have the variable "Height." The preferred method of avoiding this is to use common prefixes in Control Names, ie "txbHeight," "optNum_Monomers."

Failing to put "UnLoad Me" as the last line in a UserForm Sub can cause errors in operation.

Please remove all unused code from your book and use the Debug Menu, Compile Option to discover many errors.