Conditional Macros

billofsoo

New Member
Joined
Mar 18, 2009
Messages
4
I need assistance. I am working with a checklist that has 6 categories. The worker must enter a rating on each checklist item in each category. Once each category is completed, a number is produced in a connected cell representing a percentage of responses in each category meeting a specific criterion. Once the checklist is complete I would like the worker to be able to simply click the macro button that will set a number of PRINT jobs in motion.

I want to be able to write a CONDITIONAL macro that will always PRINT the same two worksheets as well as particular arrays of cells (each associated with a category, pre-formatted, print ready) depending on the percentage value obtained for each of the six categories. The macro would have to 'test' the percentage value for each category and PRINT an associated array only if the percentage for that category met the pre-determined criterion. For example, if the %value in C13 is greater than 50, Print O55:Q75. I am not sure if that is clear or if it is even possible.

I can give you the specifics re: the worksheet names, the cell designations, and the arrays to work with if you are willing to assist. I am a fairly new user of excel and can write simple formulas and set up simple macros - however, I am absolutely stumped as to how to do this and have about 48 schools in two school districts waiting for this tool. Can anyone help?
 
Last edited:
form what i get on what you are trying to do you will be better off using the case statment in VBA code. but you will need to be more clear on what you are doing and what you wont. may be past a picture of you sheet, but do a serch on here for case here is some code from excel help.


Select Case Statement Example

This example uses the Select Case statement to evaluate the value of a variable. The second Case clause contains the value of the variable being evaluated, and therefore only the statement associated with it is executed.
Code:
Dim Number
Number = 8 ' Initialize variable.
Select Case Number ' Evaluate Number.
Case 1 To 5 ' Number between 1 and 5, inclusive.
Debug.Print "Between 1 and 5"
' The following is the only Case clause that evaluates to True.
Case 6, 7, 8 ' Number between 6 and 8.
Debug.Print "Between 6 and 8"
Case 9 To 10 ' Number is 9 or 10.
Debug.Print "Greater than 8"
Case Else ' Other values.
Debug.Print "Not between 1 and 10"
End Select
 
Last edited by a moderator:
Upvote 0
TomB
Thanks for your response.
I can't figure out how to paste in a worksheet but I think I can make this simple.
Consider this example:

Value in A1 = 67

There is an array of data C1 to E7

The condition I want to establish is A1 being greater than 50

If the number in A1 is greater than 50, I want a way to automatically print the array of date C1:E7

I searched the sites for a good explanation of Select Case Statements...I see the code but can't find anywhere that explains where the code is inserted or is it a macro attached to a button??? I was hoping to find a way make this work without having to take a course. Does the example help at all? If I need to do a Select Case Statement, is there a site that explains from the ground up? I was hoping that a 'formula' could be entered into A1 (in above example) that would trigger printing. Does that make sense?

Thanks....


moz-screenshot.jpg
moz-screenshot-1.jpg
moz-screenshot-2.jpg
 
Upvote 0
TomB
I just saw some more on select case statements. I am assuming that this is a macro activated by a button. One the button is clicked the value in the cell is 'tested'

If I am right, then in my task of working with this checklist, I could have a macro button at the end of the checklist. The code for this single macro would 'test' each of the six values to see if they meet the criterion I set in the select case statement (statements for each of six values would be involved in the one macro).

Does this make any sense? Maybe you could clarify how these statements are used and maybe an example based on the info provided in my previous post.

Thanks TomB
 
Upvote 0

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