EdwardMartinIII
Technical User
I'm pretty new to VBA, so please forgive me if this is obvious.
Background: I'm trying to build an inspection tool. This tool reviews hundreds of conditionals (for example, "all houses must have a door.") against methods of testing (for example, "Is item on the blueprints," "Was item purchased," "Has item been inspected by City," and so forth.
For each conditional, there are one or more verification tests (see my three examples above). There are a total of six different ways to verify stuff, but each condition usually only uses 1-3 of them, and different conditions have different requirements.
Sometimes, a condition is not applicable, so it's not scored.
Here's a more concrete example:
Condition: There must be a written document describing process X
Of the six different ways to verify this, methods 2, 3, and 4 apply. 1, 5, and 6 do not.
At the moment, I have a spreadsheet with my conditions as rows and my verification methods as columns.
If a particular condition requires, say, verification #3, then in that cell, I've placed a red button that currently reads "Not verified" and the cell contains a value of "0".
If you click the button, it turns green, changes the label to “Verified!” and changes the 0 value of that cell to whatever the value SHOULD be (in most cases, “1”, but could be other values including 2, 3, 4, etc. depending on how valuable the combination is to the overall score.
What I did for each of those 900+ buttons (again, please forgive me), is that I simply copied the previous code and changed the references:
Doing that more than 900 times sucked.
What I’ve been asked to do now is to add, to each row, a button that the Inspector can click to negate an entire row, to essentially say that the Condition is not applicable. This button will make the row look “dimmer” and place a predetermined number in the “points being ixnayed” column (for each condition, this is anywhere from 1 to 7 points – I’ll have to transcribe those by hand). It’ll also check and if there are any green buttons in the row, and turn them red (using the same basic routine) and zero their values so that they aren’t inadvertently counted.
In my ideal world, there must be a smarter way than what I just did. There must be a smarter way to code a button I’ve pressed such that it kinda does this:
I can muddle along pretty well, but I don’t know how to determine, based on where the button was that was clicked, the “current” cell.
Is there a simple way to determine, if a button is clicked, what sheet/cell contains that button, and
Is there a way to use that data to create an on-the-fly algorithm to check certain ranges of cells also in that row, and
Is there a way to, if that button is clicked, to copy data from some other cell in that row to some other-other cell in that row, and
Apply some sort of color transformation that’s consistent to all cells of a certain range in that row (for example, adding, oh, 60 to each of the RGB colors).
It should be somewhat reversible, as well, but I figure that’s pretty simple once I have the other stuff nailed down. The only part that would cloud my mind is the color transformations on each cell. Right now, they are color-coded in different ways, and that color coding has to be preserved in both directions. That’s why I was thinking “add 60 to each value) because “subtract 60” gives you the original result back.
If reversed, I’m not at all worried about setting any individual buttons back to green, because the Inspector would have to reverify everything in that condition anyway, so buttons would stay red.
Ugh, I hope that wasn’t too long or complicated.
Thoughts? Ideas? Hints? I really don’t want to individually hand-code each routine...
Thanks!
Edward ![[monkey] [monkey] [monkey]](/data/assets/smilies/monkey.gif)
"Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!" -- inventor of the cat door
Background: I'm trying to build an inspection tool. This tool reviews hundreds of conditionals (for example, "all houses must have a door.") against methods of testing (for example, "Is item on the blueprints," "Was item purchased," "Has item been inspected by City," and so forth.
For each conditional, there are one or more verification tests (see my three examples above). There are a total of six different ways to verify stuff, but each condition usually only uses 1-3 of them, and different conditions have different requirements.
Sometimes, a condition is not applicable, so it's not scored.
Here's a more concrete example:
Condition: There must be a written document describing process X
Of the six different ways to verify this, methods 2, 3, and 4 apply. 1, 5, and 6 do not.
At the moment, I have a spreadsheet with my conditions as rows and my verification methods as columns.
If a particular condition requires, say, verification #3, then in that cell, I've placed a red button that currently reads "Not verified" and the cell contains a value of "0".
If you click the button, it turns green, changes the label to “Verified!” and changes the 0 value of that cell to whatever the value SHOULD be (in most cases, “1”, but could be other values including 2, 3, 4, etc. depending on how valuable the combination is to the overall score.
What I did for each of those 900+ buttons (again, please forgive me), is that I simply copied the previous code and changed the references:
Code:
Sheets("Req. A1").Select
Range("f18").Select
Doing that more than 900 times sucked.
What I’ve been asked to do now is to add, to each row, a button that the Inspector can click to negate an entire row, to essentially say that the Condition is not applicable. This button will make the row look “dimmer” and place a predetermined number in the “points being ixnayed” column (for each condition, this is anywhere from 1 to 7 points – I’ll have to transcribe those by hand). It’ll also check and if there are any green buttons in the row, and turn them red (using the same basic routine) and zero their values so that they aren’t inadvertently counted.
In my ideal world, there must be a smarter way than what I just did. There must be a smarter way to code a button I’ve pressed such that it kinda does this:
Code:
Sheets(IdentifySheetInWhichI’veClicked).Select
Range(IdentifyCellWhereButtonWasPressed).select
In the IdentifyCellWhereButtonWasPressed is a value. Copy that value to the Points Ixnayed column.
Look in B_ through H_ and if there’s a button present, do this:
{ change that button to red and change the value of that cell to “0”}
I can muddle along pretty well, but I don’t know how to determine, based on where the button was that was clicked, the “current” cell.
Is there a simple way to determine, if a button is clicked, what sheet/cell contains that button, and
Is there a way to use that data to create an on-the-fly algorithm to check certain ranges of cells also in that row, and
Is there a way to, if that button is clicked, to copy data from some other cell in that row to some other-other cell in that row, and
Apply some sort of color transformation that’s consistent to all cells of a certain range in that row (for example, adding, oh, 60 to each of the RGB colors).
It should be somewhat reversible, as well, but I figure that’s pretty simple once I have the other stuff nailed down. The only part that would cloud my mind is the color transformations on each cell. Right now, they are color-coded in different ways, and that color coding has to be preserved in both directions. That’s why I was thinking “add 60 to each value) because “subtract 60” gives you the original result back.
If reversed, I’m not at all worried about setting any individual buttons back to green, because the Inspector would have to reverify everything in that condition anyway, so buttons would stay red.
Ugh, I hope that wasn’t too long or complicated.
Thoughts? Ideas? Hints? I really don’t want to individually hand-code each routine...
Thanks!
![[monkey] [monkey] [monkey]](/data/assets/smilies/monkey.gif)
![[monkey] [monkey] [monkey]](/data/assets/smilies/monkey.gif)
"Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!" -- inventor of the cat door