another "if" "then" question

I would like a micro to evaluate say cell B7

If B7 has a value of 1  Macro A is invoked
If B7 has a value of 2  Macro B is invoked
If B7 has a value of 3  Macro C is invoked

I do I accomplish this?

Thx 


0
6/2/2006 2:02:30 PM
excel 39879 articles. 2 followers. Follow

3 Replies
390 Views

Similar Articles

[PageSpeed] 31

Have a look in vba help index for case and then select case.

-- 
Don Guillett
SalesAid Software
dguillett1@austin.rr.com
"jnsaunders" <jnsaunders@aol.net> wrote in message 
news:%23zpvx0khGHA.3496@TK2MSFTNGP02.phx.gbl...
>I would like a micro to evaluate say cell B7
>
> If B7 has a value of 1  Macro A is invoked
> If B7 has a value of 2  Macro B is invoked
> If B7 has a value of 3  Macro C is invoked
>
> I do I accomplish this?
>
> Thx
> 


0
dguillett1 (2487)
6/2/2006 2:09:18 PM
Function Bonus(performance, salary)
    Select Case performance
        Case 1
            Bonus = salary * 0.1
        Case 2, 3
            Bonus = salary * 0.09
        Case 4 To 6
            Bonus = salary * 0.07
        Case Is > 8
            Bonus = 100
        Case Else
            Bonus = 0
    End Select
End Function
Presumably performance is a range with numeric value that is being 
evaluated? I am confused how to do this.

"jnsaunders" <jnsaunders@aol.net> wrote in message 
news:%23zpvx0khGHA.3496@TK2MSFTNGP02.phx.gbl...
>I would like a micro to evaluate say cell B7
>
> If B7 has a value of 1  Macro A is invoked
> If B7 has a value of 2  Macro B is invoked
> If B7 has a value of 3  Macro C is invoked
>
> I do I accomplish this?
>
> Thx
> 


0
6/2/2006 2:31:39 PM
performance can be a value , 1,2,3 , etc., or  a cell reference containing
that value. Diito salary.

So it can be

=Bonus(1,1000)

or

=Bonus(a1,A2)

or a mix of them

-- 
 HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"jnsaunders" <jnsaunders@aol.net> wrote in message
news:%23PNmEFlhGHA.4368@TK2MSFTNGP03.phx.gbl...
> Function Bonus(performance, salary)
>     Select Case performance
>         Case 1
>             Bonus = salary * 0.1
>         Case 2, 3
>             Bonus = salary * 0.09
>         Case 4 To 6
>             Bonus = salary * 0.07
>         Case Is > 8
>             Bonus = 100
>         Case Else
>             Bonus = 0
>     End Select
> End Function
> Presumably performance is a range with numeric value that is being
> evaluated? I am confused how to do this.
>
> "jnsaunders" <jnsaunders@aol.net> wrote in message
> news:%23zpvx0khGHA.3496@TK2MSFTNGP02.phx.gbl...
> >I would like a micro to evaluate say cell B7
> >
> > If B7 has a value of 1  Macro A is invoked
> > If B7 has a value of 2  Macro B is invoked
> > If B7 has a value of 3  Macro C is invoked
> >
> > I do I accomplish this?
> >
> > Thx
> >
>
>


0
bob.NGs1 (1661)
6/2/2006 2:52:14 PM
Reply:

Similar Artilces:

another if-then question
This may actually be a find-replace question. At any rate, I am not sur how to formulate this. What I am trying to do is check a specific column which contain numbers and check to see if any numbers contain characters (that ar not numbers) preceding the number. If a number DOES contain a characte that is not a number preceding that number, then move that characte behind the last character in another column. For example, I want to check all the numbers in column D, if a numbe in that column contains any character that is not a number - such a *86, then the asterisk would be moved to column C...

If "yes" then require data in another field
I have two fields on a form: one a "check box" and another a "combo list" If the check box = Yes, then I want the field for the combo list to require data. I can make it go the field that I want the date inserted, but I cannot seem to figure out how to make it mandatory for the user to insert data from the drop down list if the check box = yes. Use the Exit event of the ComboBox and Cancel = True If Len(Me.ComboBox & "") = 0 Sheryl wrote: >I have two fields on a form: one a "check box" and another a "combo list" > >If t...

If Info In Cell Then Formula In Another
Hello, I am trying to get a cell with date information in it to enable a formula of some other cells to happen, in other words when a date is not entered that particular cell is empty therefore the corresponding formula cells are not enabled. Here is a function that works but only when the referanced cell has either "Pending/Issued/Declined" =IF(E4="Issued",F4*H4,IF(E4="Declined",F4*0,IF(E4="Pending",0))). I would like this function to result correctly with a date entry in the referanced cell rather then wording. How can I do this? -- Thank y...

If then statement question....
I use Excel 2000 9.0 as a pruchasing program. I would like for Excel to recognize which vendor I enter into column c, and then automatically enter who my sales rep is into column J. I also would use this same method to recognize item descriptions in column D and automatically input the respective part numbers. Thanks in advance, The feature you are looking for is called VLOOKUP........ Your formula will look something like this......... =VLOOKUP(C1,LISTOFREPS,2,FALSE) Check the Help section, and post back if you run into problems. Vaya cno Dios, Chuck, CABGx3 "atlcasework" wr...

for loop with If then question
Morning all. I'm looking to set up an automatic password sheet protection tool and there are only specific elements that I need protected on the worksheets in my workbooks. As such, my goal is to look for a value, in a single column, and if the value exists in one cell, protect that row. All other rows will remain unprotected. As I think about this, it seems to me that I'd need a for loop to iterate through the rows of that one column, and then use an IF statement to look for a value. Part of my struggle is that not all worksheets start at the same start row. N...

A macro to check range and then check another range if falset-then
Hi – I have been trying to work out a macro. I am looking for a macro that will check 2 things....then do something. The first is if a particular cell contains a given value. Lets say Sheets("sheet1").Range("D3") should equal "Year 1" if true. Next is if a range of cell values in are blank, Sheets("Sheet1").Range("D6:G48") should be blank. If both these are true then I want the macro to copy a range of cells from Sheets("Sheet2").Range("AR5:AR47") to Sheets("Sheet1").Range("D6:D48"). If false then...

Help! Probably dumb newbie question but need help with if/then??
Thanks in advance to anyone that can help. I have looked through many other posts and don't quite think I am asking the right search questions. Here goes: Lets say I am creating a schedule and when I type in an employee number in A1 how do I get excel to then enter data that I specify (name, skills, whatever) in subsequent cells (b2, b3, etc)??? Vlookup should do what you want. Check out this web page of Debra Dalgleish on the function: http://www.contextures.com/xlFunctions02.html -- HTH, RD --------------------------------------------------------------------------- Please k...

another "if" "then" question
I would like a micro to evaluate say cell B7 If B7 has a value of 1 Macro A is invoked If B7 has a value of 2 Macro B is invoked If B7 has a value of 3 Macro C is invoked I do I accomplish this? Thx Have a look in vba help index for case and then select case. -- Don Guillett SalesAid Software dguillett1@austin.rr.com "jnsaunders" <jnsaunders@aol.net> wrote in message news:%23zpvx0khGHA.3496@TK2MSFTNGP02.phx.gbl... >I would like a micro to evaluate say cell B7 > > If B7 has a value of 1 Macro A is invoked > If B7 has a value of 2 Macro B is invoked >...

If/Then Function Question
I need the formula to recognize that what it is looking at is a date not a calculation. For example: Column A is a date in the form of 1/31/2004 Column B is the If/Then function in the form of If A1>=1/31/2004, then Y value if false N. The computer is calculating 1/31/2004 and not recognizing that it is a date. How can I make the If/Then formula recognize column A as a date and not a calculation? I have already went down column A and verified with Excel that the cells are in date format. Thanks for your help. =If(A1>=--"2004-01-31","Y","N") -- HTH R...

If/Then Question
Because I have no idea what to call this since I am a newbie with Excel, my searches in google did not work. Hopefully, I can explain what I need without coming off sounding like an idiot... hell, I didn't even know what to put in the subject line. Anyway... I run an online NCAA Football league and we award points to coaches for their successes, but with 119 teams, keeping track can be a real pain. Thus, I am trying to make it as easy as possible through Excel. Wthin the sheet, their are a number of variables, but this is what I am focusing on. We award 5 points for a victory. As it ...

for each and if then questions
Hello There, I have a table with "date Recieved" and "QTY" headers. In the form I would like textboxes to display quantity's for day totals, week totals and month totals from a date selected in a calender. I cannot begin to figure out how to code this correctly but here is the jist of what I have. For each item in [date Recieved] If item = calender0.value then daytotal = ? else if item = date("ww", calender0.value) then weektotal = ? else if item = month(calender0.value) then montht...

how to: if a value is entered in one row, then associated data is cummulatively added to a 'total' on another sheet ?
Excel Version : 12.2.3 OS X 10.6.2 Intel Hi =97 I am very new to Excel, and am learning a lot, but have found it difficult to work out a new problem. I am trying to nut out a formula to do the following (I have searched all over, but realise I don't really know what my search terms should be). For arguments sake, I have two worksheets, A and B. Worksheet A is used as a meta-summary of what will happen elsewhere in the Workbook. Worksheet B is where the raw data is entered (as it will in C, D, E, etc, in the future). I have created a drop down list of categories for use in Wo...

If adjancent cell contains text then ignore, otherwise copy and paste multiple values in one column to another column
Hi all I currently have a column (say column A) that contains a list of numbers.= =20 In column B, in every 15th row, e.g. row 15, 30, 45 etc, there may or may n= ot be a comment. Where there is a comment, this nullifies the 15 rows of nu= mbers in column A, e.g. if there is a comment in B30, the numbers between A= 30 and A44 are nullified. The comments may be one or two words but vary eno= rmously so I cannot say it will be either this word or that word.=20 Where there are no comments in column B, I would like to copy and paste the= 15 corresponding numbers in column A into column C. For ...

if/then question
Here's what I hope is a pretty basic question. I have 5 rows of inventory data. They are the following: A1: Product Name A2: Product Cost A3: Maximum Qty. Desired on Hand A4: Minimum Qty. Desired on Hand A5: Quantity on Hand Basically, it looks like this: Widget X | 25 | 10 | 4 | 5 I'd like to figure out how to write a formula for cell A6 that would tell me the following: If A5 is greater or equal to A4, then I'd like A6 = 0. If A5 is less than A4, then I'd like A6 = (A3-A5) * A2. Is this possible? Many thanks, Brendan Brendan this should work =IF(A5>...

If
How would I write a formula to handle this problem? If the value in cell D20 is ‘U18’ then the result in cell D6 is a ‘0’ however if the value in D20 is anything else then the result in cell D6 is the value in N5 Try this entered in D6: =IF(D20="U18",0,N5) Or: Assuming N5 is a numeric value. =(D20<>"U18")*N5 -- Biff Microsoft Excel MVP "Ksean" <Ksean@discussions.microsoft.com> wrote in message news:D25E41AD-1640-45BC-9E87-BBC09E879488@microsoft.com... > How would I write a formula to handle this problem? > If t...

IF THEN QUESTION???
Perhaps this has been discussed in the past. I have 30 worksheets in an EXCEL file. The #1 worksheet is the main informational sheet. I'm trying to obtain the formula that would allow me to retrieve a specific data from any of the given worksheet. Example: If J7 is 2, I would like for the system to go to worksheet #2 and obtain the number from cell d39. If tomorrow I change J7 to 25, I would like it to go to worksheet #25 and obtain the number from d39. Your assistance is greatly appreciated Thanks in advance, Mike Have a look at the INDIRECT function to create this formula ...

IF and THEN question
Hello, I have a spreadsheet where a certain column display what is to be done with the information. For example: A B C D 123 456 789 DELETE 987 654 321 ADD What I'd like to do in column E is to make a formula that says: If D1 equals DELETE, then put the value DEL in E1 If D1 had been ADD, then I would want the value PUT in E1 Does this make any sense? Thanks for any help! Thomas --- Message posted from http://www.ExcelForum.com/ Hi Thomas put the following in E1: =IF(D1="DELETE","DEL",IF(D1="ADD","PUT",&quo...

If / Then Question
How would I do this: IF A1="N" then I need A2 and A3 to="N/A -- pkniven ----------------------------------------------------------------------- pknivens's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=2767 View this thread: http://www.excelforum.com/showthread.php?threadid=47531 pknivens Wrote: > How would I do this: > > IF A1="N" then I need A2 and A3 to="N/A" Hi pknivens In A2 and A3 use this formula > =IF(A1="N","N/A",""), this will return blank if A1 is not N, if you want it...

if- then question
Is it possible to compare two rows and then based on the value, assign a character to occupy and adjacent column in the same row. For example, I want to compare all of the numbers in column B, with th numbers in column D, if B is greater than D, I want to put the lette "W" in the adjacent column (in the same row). If B is less than D, want to put the letter "L" in the adjacent column. Is this possible -- Message posted from http://www.ExcelForum.com Hi enter the following in the adjacent row (lets say in column E, cell E1) =IF(B1>D1,"W",IF(B1<D1,"...

If then Question
Hello, How do I set and if statement to be true if the cell contains a number less than 1? I have tried the following: =IF(D25=<1,"ERROR","") This works for number but you can type in letters and it still comes out true. How do you set it so that it only comes out true if a number less than 1 is entered? Just leave out the =before < -- Don Guillett SalesAid Software donaldb@281.com "Ben" <anonymous@discussions.microsoft.com> wrote in message news:031e01c3dae6$8d260c00$a401280a@phx.gbl... > Hello, > > How do I set and if statement t...

IF_THEN_ELSE question
Here's what I have: A1 = .75 (that's point seventy-five, less than zero) B1 = the argument =IF(A1<0,A1,0) The result I get in B1 is 0 when it should get the number in A! which is .75 (point seventy-five). If A1 is 3 (or any number greater than zero), I get whatever the number in A1 is, but I should get 0.. If I change the argument to >0 (greater than zero), it always gives me the number in A1, even when it's less than 0. Yes, I triple-checked all the numbers I put in A1 to make sure there were no misplaced decimals. Can someine tell me where I'm going wrong? Thanks...

If Then Text Question
I have a list of customer numbers and serial numbers. I need a formula that will find the customer number in a list, then fill the cell with the serial number (contains alpha and numeric characters, ie BBB1001). Example: If the value in cell A2 is equal to 1234, then find 1234 in a range (B2:B100), and retrive the serial number in a range (C2:C100). Thank you for your help. Hi use =VLOOKUP(A2,B2:C100,2,0) -- Regards Frank Kabel Frankfurt, Germany Debi wrote: > I have a list of customer numbers and serial numbers. I need a > formula that will find the customer number in a list, t...

If/Then Formula Question
I am attempting to create a timesheet, where if a particular cell is clicked on, the current time/date stamp will generate via the Now() function. I am having trouble with how to indicate that the timestamp should be entered if the cell is clicked on. Also, can the timestamp be displayed in the same cell, take cell A1 for example. Any assistance is appreciated. I have both 2000 and 2003 available. Put the following code in the worksheet's code module (right-click the tab and choose View Code). Private Sub Worksheet_SelectionChange(ByVal Target As Range) With Target If .Add...

If.. AND If.. Then coding question
I use a form with check boxes. I currently have code that If one box is checked Then change a list to "1" Private Sub XXX_AfterUpdate() If (Me.XXX = -1) Then Me.List117 = "1" End If I want to write a code that if two (or more) boxes are checked Then change list to 2 I tried this but it didn't work Private Sub XXX_AfterUpdate() If (Me.XXX = -1) and If (If Me.YYY = -1 ) Then Me.List117 = "2" End If I would appreciate any help. Try this Private Sub XXX_AfterUpdate() If Me.XXX = -1 and Me.YYY = -1 Then Me.List117 = "2"...

If/Then Formula Question: Can Excel Be Made to Read the Computer's Date Setting?
This might be asking a bit much of Excel, but here goes. I have a membership list. When you pay your membership it is good for one year. I enter the expiration date in cell A1. In cell B1 I want to have an If/Then formula that states Y if their membership is active, N if it isn't. My issue is that each person's expiration date is different, so my formula in column B will be different for everyone. I want to be able to have the If/Then function look at the computer's date as part of the function. i.e. The normal way is listed below, but each person would need a different day in o...