Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Please ignore the previous most with the same name, something went goofy when
I tried to post. Is there any way to delete the first post? What I am looking to do is call one of three macros depending on the contents of a cell. If I have my code to look like below, the second macro is run regardless if it is true or not. Sub Special_Terms() If AH13 = AH6 Then Call Special_Terms_Frank If AH13 = AH7 Then Call Special_Terms_Jack Else Call Delete_Special_Terms End If End If End Sub If I change the code that is below, it returns the first macro regardless of it being true. Sub Special_Terms() If AH13 = AH6 Then Call Special_Terms_Frank ElseIf AH13 = AH7 Then Call Special_Terms_Jack Else Call Delete_Special_Terms End If End Sub Can anyone explain what the difference in each of the two options above and how do I make only the true macro run? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
AH13 and AH6 are variables which you haven't assigned anything to, so their
values are zero and, hence, always equal to each other. I'm assuming those are supposed to be cell addresses and you want to compare the contents of those cells, right? Try this... Sub Special_Terms() If Range("AH13").Value = Range("AH6").Value Then Call Special_Terms_Frank ElseIf Range("AH13").Value = Range("AH7").Value Then Call Special_Terms_Jack Else Call Delete_Special_Terms End If End Sub -- Rick (MVP - Excel) "Homer" wrote in message ... Please ignore the previous most with the same name, something went goofy when I tried to post. Is there any way to delete the first post? What I am looking to do is call one of three macros depending on the contents of a cell. If I have my code to look like below, the second macro is run regardless if it is true or not. Sub Special_Terms() If AH13 = AH6 Then Call Special_Terms_Frank If AH13 = AH7 Then Call Special_Terms_Jack Else Call Delete_Special_Terms End If End If End Sub If I change the code that is below, it returns the first macro regardless of it being true. Sub Special_Terms() If AH13 = AH6 Then Call Special_Terms_Frank ElseIf AH13 = AH7 Then Call Special_Terms_Jack Else Call Delete_Special_Terms End If End Sub Can anyone explain what the difference in each of the two options above and how do I make only the true macro run? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thank you Rick. Your additions work well.
By just having AH13 and so on.. doesn't point to a cell. By adding Range("AH13").value points it to a cell. This will work for one page in a sheet. What if I wanted to be able to have it work for all pages in the sheet? I tried adding Additional cells but it didn't work. If it should have, the problem may be in the macro it is trying to call. Thanks "Rick Rothstein" wrote: AH13 and AH6 are variables which you haven't assigned anything to, so their values are zero and, hence, always equal to each other. I'm assuming those are supposed to be cell addresses and you want to compare the contents of those cells, right? Try this... Sub Special_Terms() If Range("AH13").Value = Range("AH6").Value Then Call Special_Terms_Frank ElseIf Range("AH13").Value = Range("AH7").Value Then Call Special_Terms_Jack Else Call Delete_Special_Terms End If End Sub -- Rick (MVP - Excel) "Homer" wrote in message ... Please ignore the previous most with the same name, something went goofy when I tried to post. Is there any way to delete the first post? What I am looking to do is call one of three macros depending on the contents of a cell. If I have my code to look like below, the second macro is run regardless if it is true or not. Sub Special_Terms() If AH13 = AH6 Then Call Special_Terms_Frank If AH13 = AH7 Then Call Special_Terms_Jack Else Call Delete_Special_Terms End If End If End Sub If I change the code that is below, it returns the first macro regardless of it being true. Sub Special_Terms() If AH13 = AH6 Then Call Special_Terms_Frank ElseIf AH13 = AH7 Then Call Special_Terms_Jack Else Call Delete_Special_Terms End If End Sub Can anyone explain what the difference in each of the two options above and how do I make only the true macro run? |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm not 100% sure of your question (you should always post your question
with details of what your layout is and what you want to end up with afterward, with examples if possible); but, to get you started, you can point the range at any worksheet you want by prefacing the range with a Worksheets property call. For example... Range("A1") points to A1 on the Active worksheet, whereas... Worksheets("Main Data").Range("A1") points to A1 on the worksheet named "Main Data". -- Rick (MVP - Excel) "Homer" wrote in message ... Thank you Rick. Your additions work well. By just having AH13 and so on.. doesn't point to a cell. By adding Range("AH13").value points it to a cell. This will work for one page in a sheet. What if I wanted to be able to have it work for all pages in the sheet? I tried adding Additional cells but it didn't work. If it should have, the problem may be in the macro it is trying to call. Thanks "Rick Rothstein" wrote: AH13 and AH6 are variables which you haven't assigned anything to, so their values are zero and, hence, always equal to each other. I'm assuming those are supposed to be cell addresses and you want to compare the contents of those cells, right? Try this... Sub Special_Terms() If Range("AH13").Value = Range("AH6").Value Then Call Special_Terms_Frank ElseIf Range("AH13").Value = Range("AH7").Value Then Call Special_Terms_Jack Else Call Delete_Special_Terms End If End Sub -- Rick (MVP - Excel) "Homer" wrote in message ... Please ignore the previous most with the same name, something went goofy when I tried to post. Is there any way to delete the first post? What I am looking to do is call one of three macros depending on the contents of a cell. If I have my code to look like below, the second macro is run regardless if it is true or not. Sub Special_Terms() If AH13 = AH6 Then Call Special_Terms_Frank If AH13 = AH7 Then Call Special_Terms_Jack Else Call Delete_Special_Terms End If End If End Sub If I change the code that is below, it returns the first macro regardless of it being true. Sub Special_Terms() If AH13 = AH6 Then Call Special_Terms_Frank ElseIf AH13 = AH7 Then Call Special_Terms_Jack Else Call Delete_Special_Terms End If End Sub Can anyone explain what the difference in each of the two options above and how do I make only the true macro run? |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks again Rick. You have cleared up a few things. I'm going to try to
figure a few things out. Thanks again, Don "Rick Rothstein" wrote: I'm not 100% sure of your question (you should always post your question with details of what your layout is and what you want to end up with afterward, with examples if possible); but, to get you started, you can point the range at any worksheet you want by prefacing the range with a Worksheets property call. For example... Range("A1") points to A1 on the Active worksheet, whereas... Worksheets("Main Data").Range("A1") points to A1 on the worksheet named "Main Data". -- Rick (MVP - Excel) "Homer" wrote in message ... Thank you Rick. Your additions work well. By just having AH13 and so on.. doesn't point to a cell. By adding Range("AH13").value points it to a cell. This will work for one page in a sheet. What if I wanted to be able to have it work for all pages in the sheet? I tried adding Additional cells but it didn't work. If it should have, the problem may be in the macro it is trying to call. Thanks "Rick Rothstein" wrote: AH13 and AH6 are variables which you haven't assigned anything to, so their values are zero and, hence, always equal to each other. I'm assuming those are supposed to be cell addresses and you want to compare the contents of those cells, right? Try this... Sub Special_Terms() If Range("AH13").Value = Range("AH6").Value Then Call Special_Terms_Frank ElseIf Range("AH13").Value = Range("AH7").Value Then Call Special_Terms_Jack Else Call Delete_Special_Terms End If End Sub -- Rick (MVP - Excel) "Homer" wrote in message ... Please ignore the previous most with the same name, something went goofy when I tried to post. Is there any way to delete the first post? What I am looking to do is call one of three macros depending on the contents of a cell. If I have my code to look like below, the second macro is run regardless if it is true or not. Sub Special_Terms() If AH13 = AH6 Then Call Special_Terms_Frank If AH13 = AH7 Then Call Special_Terms_Jack Else Call Delete_Special_Terms End If End If End Sub If I change the code that is below, it returns the first macro regardless of it being true. Sub Special_Terms() If AH13 = AH6 Then Call Special_Terms_Frank ElseIf AH13 = AH7 Then Call Special_Terms_Jack Else Call Delete_Special_Terms End If End Sub Can anyone explain what the difference in each of the two options above and how do I make only the true macro run? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to work multiple ifs | Excel Programming | |||
need a function that will work using multiple work books and sheet | Excel Worksheet Functions | |||
Getting multiple IF statements to work | Excel Discussion (Misc queries) | |||
Counting dates in multiple work sheets and work books | Excel Discussion (Misc queries) | |||
Multiple Work Sheets | Excel Worksheet Functions |