Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel '07 VB error using 'do' loops

Status
Not open for further replies.

TFlanagan

MIS
Mar 19, 2009
8
US
I am trying to do similar operations on several different worksheets in a workbook via a macro. The operation for each sheet is being done via a 'Do Until' loop.

The first loop operation starts with this line:
Do Until Cells(Tomorrow_row, 1).Text = "#VALUE!"

The second loop:
Do Until Cells(Tomorrow_row, 13).Text = "#VALUE!"

The third loop:
Do Until Cells(Tomorrow1_row, 1).Text = "#VALUE!"

The first two loop operations execute without incident. The third crashes the macro with:
"Run-time error '1004':
Application-defined or object-defined error"

All of the microsoft help, which is of no help whatsoever, as usual, says this is an error which doesn't map to any defined error. Gee, thanks Billy.

The Debug key highlights the third Do Until line. I've checked my spelling, syntax and the variable definition. I don't know what else it could be.
 
I suspect that your woes come from you not specifying which sheet you're working on. Show us all of your code so we can figure out what's going on?
 



Why would you have #VALUE! errors on your sheet? I suspect that you have filled yet-to-be-used rows with formulas; a less than ideal practice.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
1004 usually implies an invalid reference somewhere - either a bad sheet name or Tomorrow1_row has an invalid value or no value

Will need to see the loop code to be able to understand better

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top