|
|
Subject:
Excel macro question
Category: Computers > Software Asked by: macaonghus-ga List Price: $2.00 |
Posted:
24 Oct 2004 13:20 PDT
Expires: 23 Nov 2004 12:20 PST Question ID: 419425 |
The macro below has an error, detailed below within the code as a comment. I can't remember how to fix it, do I add an End or a something somewhere? Thank you --------------------------- Sub Macro2() x = Range("l1") y = Range("l1") z = Range("l1") For game1 = 1 To x a = Range("O1").Offset(game1, 0).Select b = Range("P1").Offset(game1, 0).Select c = Range("Q1").Offset(game1, 0).Select For game2 = 1 To y d = Range("O1").Offset(game2, 0).Select e = Range("P1").Offset(game2, 0).Select f = Range("Q1").Offset(game2, 0).Select For game3 = 1 To z Range("h1") = game1 Range("h2") = game2 Range("h3") = game3 g = Range("O1").Offset(game3, 0).Select h = Range("P1").Offset(game3, 0).Select i = Range("Q1").Offset(game3, 0).Select If a * d * g > 0 Then If a * d * h > 0 Then If a * d * i > 0 Then If a * e * g > 0 Then If a * e * h > 0 Then If a * e * i > 0 Then If a * f * g > 0 Then If a * f * h > 0 Then If a * f * i > 0 Then If b * d * g > 0 Then If b * d * h > 0 Then If b * d * i > 0 Then If b * e * g > 0 Then If b * e * h > 0 Then If b * e * i > 0 Then If b * f * g > 0 Then If b * f * h > 0 Then If b * f * i > 0 Then If c * d * g > 0 Then If c * d * h > 0 Then If c * d * i > 0 Then If c * e * g > 0 Then If c * e * h > 0 Then If c * e * i > 0 Then If c * f * g > 0 Then If c * f * h > 0 Then If c * f * i > 0 Then Range("c5") = a Range("d5") = b Range("e5") = c Range("c6") = d Range("d6") = e Range("e6") = f Range("c7") = g Range("d7") = h Range("e7") = i Next game3 'THIS IS MY ERROR. I GET A --NEXT WITHOUT FOR-- ERROR Next game2 Next game1 End Sub |
|
Subject:
Re: Excel macro question
Answered By: aht-ga on 24 Oct 2004 13:44 PDT Rated: |
macaonghus-ga: Hello again! The reason you are getting the compile error "Next without For", is because you are missing all of the "End If" statements needed to close off the If statements: Sub Macro2() x = Range("l1") y = Range("l1") z = Range("l1") For game1 = 1 To x a = Range("O1").Offset(game1, 0).Select b = Range("P1").Offset(game1, 0).Select c = Range("Q1").Offset(game1, 0).Select For game2 = 1 To y d = Range("O1").Offset(game2, 0).Select e = Range("P1").Offset(game2, 0).Select f = Range("Q1").Offset(game2, 0).Select For game3 = 1 To z Range("h1") = game1 Range("h2") = game2 Range("h3") = game3 g = Range("O1").Offset(game3, 0).Select h = Range("P1").Offset(game3, 0).Select i = Range("Q1").Offset(game3, 0).Select If a * d * g > 0 Then If a * d * h > 0 Then If a * d * i > 0 Then If a * e * g > 0 Then If a * e * h > 0 Then If a * e * i > 0 Then If a * f * g > 0 Then If a * f * h > 0 Then If a * f * i > 0 Then If b * d * g > 0 Then If b * d * h > 0 Then If b * d * i > 0 Then If b * e * g > 0 Then If b * e * h > 0 Then If b * e * i > 0 Then If b * f * g > 0 Then If b * f * h > 0 Then If b * f * i > 0 Then If c * d * g > 0 Then If c * d * h > 0 Then If c * d * i > 0 Then If c * e * g > 0 Then If c * e * h > 0 Then If c * e * i > 0 Then If c * f * g > 0 Then If c * f * h > 0 Then If c * f * i > 0 Then Range("c5") = a Range("d5") = b Range("e5") = c Range("c6") = d Range("d6") = e Range("e6") = f Range("c7") = g Range("d7") = h Range("e7") = i End If End If End If End If End If End If End If End If End If End If End If End If End If End If End If End If End If End If End If End If End If End If End If End If End If End If End If Next game3 Next game2 Next game1 End Sub Hope this helps, aht-ga Google Answers Researcher |
macaonghus-ga rated this answer: |
|
There are no comments at this time. |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |