Home |
Search |
Today's Posts |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Carl,
My understanding of your problem was that the inner loop did not terminate when it was rerun by the outer loop the second time. This is what should happen if you don't rezero the Y variable after completion of each inner loop. Note that your code increments the Y variable (column offset) by 1 until it equals 119. Then the inner loop terminates ("Loop Until Y = 119"). The outer loop then causes a row offset downward and then reruns the inner loop. However, Y equals 119 at the start of the second run of the inner loop and is immediately incremented by 1 and therefore equals 120. At this point, the statement "Loop Until Y = 119" will have no effect because Y already exceeds 119 and continues to be incremented. Therefore, the inner loop cannot self-terminate. Consequentially, your code continues to reference one column to the right until it attempts to reference beyond the last column in the worksheet. This will cause Error 1004. If you run the code with the line that rezeros the Y variable then this won't happen. I assumed that the named ranges "ONHAND" and "Received" were single cell ranges on the active sheet. I ran your code after creating these named ranges and received the Error 1004 message. I then ran it with the line that rezeros the Y variable and it worked according to my understanding of your intention. Please advise if you have run the code with the line that rezeros the Y variable and if the named ranges "ONHAND" and "Received" refer to single cell ranges on the active sheet. Also, since there are more than one version of Error 1004 message, please advise of what else it says. Regards, Greg |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
error 1004 (VBA) | Setting up and Configuration of Excel | |||
Run time error 1004, General ODBC error | New Users to Excel | |||
Runtime error '1004' General ODBC error | New Users to Excel | |||
Excel 2003 Macro Error - Runtime error 1004 | Excel Discussion (Misc queries) | |||
Error no. 1004 | Excel Programming |