Home |
Search |
Today's Posts |
#1
|
|||
|
|||
Run Macro From If Statement
I could be way off here, but... I am trying to do an IF statement and then depending on the answer run a macro or end the statement. In Lotus I was able to do the BRANCH macro, but it seems you cannot do that in excel. This is an example what I'm trying to accomplish. If the value of cell M50<= to 25 then do nothing - if it's greater than I need another macro to run. Thank you for any help!! -- Paige ------------------------------------------------------------------------ Paige's Profile: http://www.excelforum.com/member.php...o&userid=23096 View this thread: http://www.excelforum.com/showthread...hreadid=376081 |
#2
|
|||
|
|||
Hi Paige
You need a event to do this because formulas can only return values You can use the example on this page http://www.rondebruin.nl/mail/change.htm You see that this example run a mail macro -- Regards Ron de Bruin http://www.rondebruin.nl "Paige" wrote in message ... I could be way off here, but... I am trying to do an IF statement and then depending on the answer run a macro or end the statement. In Lotus I was able to do the BRANCH macro, but it seems you cannot do that in excel. This is an example what I'm trying to accomplish. If the value of cell M50<= to 25 then do nothing - if it's greater than I need another macro to run. Thank you for any help!! -- Paige ------------------------------------------------------------------------ Paige's Profile: http://www.excelforum.com/member.php...o&userid=23096 View this thread: http://www.excelforum.com/showthread...hreadid=376081 |
#3
|
|||
|
|||
I can't get it to work. How caan I run it from within a Sub? What I am doing is automating a form. When the user chooses the quantities and products it then sorts them and deletes any rows not needed. If there are more than 25 lines I need it to one thing and if it's less another thing. Below is my code up until where I'm stuck. (It may be kind of ugly as I'm quite new to excel...) Sub AfterSort() Range("A2:I997").Select Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, Key2:=Range("E2") _ , Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _ False, Orientation:=xlTopToBottom Application.Goto Reference:="PODATABASE" ActiveCell.FormulaR1C1 = "end" Selection.End(xlUp).Select ActiveCell.Offset(1, 0).Activate Range(Selection, Selection.End(xlDown)).Select Selection.EntireRow.Delete Application.Goto Reference:="END1" Selection.End(xlUp).Select ActiveCell.Offset(1, 0).Range("A1").Select Selection.End(xlToRight).Select Range(Selection, Selection.End(xlDown)).Select Selection.ClearContents ActiveCell.Offset(0, -1).Range("A1").Select Range("A2:I27").Select Selection.Sort Key1:=Range("I2"), Order1:=xlAscending, Key2:=Range("E2") _ , Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _ False, Orientation:=xlTopToBottom ActiveCell.Select Range("A2:H27").Select Selection.Copy Sheets("Purchase Order").Select Application.Goto Reference:="POQTY" ActiveSheet.Paste Application.Goto Reference:="POQTY" ActiveWorkbook.Names("PODATABASE").Delete ActiveWorkbook.Names("PONUMBER").Delete ActiveWorkbook.Names("POQTY").Delete ActiveWorkbook.Names("POREQUIREDBY").Delete ActiveWorkbook.Names("POVALUE").Delete ActiveWorkbook.Names("POMERGE").Delete ActiveWorkbook.Names("POJOBNO").Delete ActiveWorkbook.Names("POVENDOR").Delete 'THIS IS WHERE I NEED TO HAVE IT CHOOSE BETWEEN CONTINUING IF THE TOTAL IS MORE THAN 25 OR END CODE IF 25 OR LESS End Sub -- Paige ------------------------------------------------------------------------ Paige's Profile: http://www.excelforum.com/member.php...o&userid=23096 View this thread: http://www.excelforum.com/showthread...hreadid=376081 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
can i use an IF Statement to run a macro? | Excel Worksheet Functions | |||
If statement in a Macro | Excel Discussion (Misc queries) | |||
how do i change the expense statement template macro | Excel Worksheet Functions | |||
if statement in Macro | Excel Worksheet Functions | |||
Macro and If Statement | Excel Discussion (Misc queries) |