Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Paige
 
Posts: n/a
Default 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   Report Post  
Ron de Bruin
 
Posts: n/a
Default

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   Report Post  
Paige
 
Posts: n/a
Default


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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
can i use an IF Statement to run a macro? Davidrowland88 Excel Worksheet Functions 2 February 11th 05 12:45 PM
If statement in a Macro Dave Excel Discussion (Misc queries) 1 January 29th 05 12:17 AM
how do i change the expense statement template macro Mad2691 Excel Worksheet Functions 1 January 28th 05 01:21 PM
if statement in Macro John Excel Worksheet Functions 6 December 29th 04 07:17 PM
Macro and If Statement SATB Excel Discussion (Misc queries) 2 December 3rd 04 04:46 PM


All times are GMT +1. The time now is 12:03 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"