ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Do Until syntax problem (https://www.excelbanter.com/excel-programming/375580-do-until-syntax-problem.html)

excelnut1954

Do Until syntax problem
 
Can someone please tell me what is wrong with this command?

Do Until Range("Current_Date").Value - ActiveCell.Value < 361

I tried to add at the end,

Do Until Range("Current_Date").Value - ActiveCell.Value < 361 = True

but it still errors out.

Any suggestions? I've browsed examples here, and couldn't find anything
similar to what I'm doing.
Thanks,
J.O.


[email protected]

Do Until syntax problem
 
The second form is wrong. The first form can be made clearer if you
include parentheses:
Do Until (Range("Current_Date").Value - ActiveCell.Value) < 361

But in either case it should not error out. Are you sure the range
"Current_Date" is correct? If not the error should be on the Range
Method, not the "Do" or "Until" statements.

Hope this gets you started,
Dom



excelnut1954 wrote:
Can someone please tell me what is wrong with this command?

Do Until Range("Current_Date").Value - ActiveCell.Value < 361

I tried to add at the end,

Do Until Range("Current_Date").Value - ActiveCell.Value < 361 = True

but it still errors out.

Any suggestions? I've browsed examples here, and couldn't find anything
similar to what I'm doing.
Thanks,
J.O.



Tom Ogilvy

Do Until syntax problem
 
of course I had a defined name Current_Date, it contained a date and it only
referenced a single cell.

--
Regards,
Tom Ogilvy



"excelnut1954" wrote:

Can someone please tell me what is wrong with this command?

Do Until Range("Current_Date").Value - ActiveCell.Value < 361

I tried to add at the end,

Do Until Range("Current_Date").Value - ActiveCell.Value < 361 = True

but it still errors out.

Any suggestions? I've browsed examples here, and couldn't find anything
similar to what I'm doing.
Thanks,
J.O.



Tom Ogilvy

Do Until syntax problem
 
Sub ABC()
Range("A3").Select

Do Until Range("Current_Date").Value - ActiveCell.Value < 361
ActiveCell.Offset(1, 0).Select
Loop
End Sub

worked fine for me. It stopped on 10/25/2005

--
Regards,
Tom Ogilvy



"excelnut1954" wrote:

Can someone please tell me what is wrong with this command?

Do Until Range("Current_Date").Value - ActiveCell.Value < 361

I tried to add at the end,

Do Until Range("Current_Date").Value - ActiveCell.Value < 361 = True

but it still errors out.

Any suggestions? I've browsed examples here, and couldn't find anything
similar to what I'm doing.
Thanks,
J.O.



excelnut1954

Do Until syntax problem
 
Thanks for the responses. What I'm getting is a Type Mis Match error.
What I was trying to do is to replace this line
Do Until IsEmpty(ActiveCell.Value)
with the one I have above. I inserted a line to sort the list by date,
with the older records at the top. I was just trying to see if I could
save a bit of time having it read only part of the list, instead of
having to read all the 600 records.

Anyway, the original works fine. So, I don't want to spend too much
time on it.
At this point, I'm more interested in why it didn't work, for future
reference. I haven't yet put equations in any of my Do Until commands,
so I thought I had the syntax wrong. Obviously there's something else
at play on why the original line works ok in the macro, but not the new
line.
Thanks
J.O.
Tom Ogilvy wrote:
Sub ABC()
Range("A3").Select

Do Until Range("Current_Date").Value - ActiveCell.Value < 361
ActiveCell.Offset(1, 0).Select
Loop
End Sub

worked fine for me. It stopped on 10/25/2005

--
Regards,
Tom Ogilvy



"excelnut1954" wrote:

Can someone please tell me what is wrong with this command?

Do Until Range("Current_Date").Value - ActiveCell.Value < 361

I tried to add at the end,

Do Until Range("Current_Date").Value - ActiveCell.Value < 361 = True

but it still errors out.

Any suggestions? I've browsed examples here, and couldn't find anything
similar to what I'm doing.
Thanks,
J.O.




Tom Ogilvy

Do Until syntax problem
 
Since you only originally posted 1 line of code and now one more, it would
be hard to say.

Perhaps the activecell doesn't contain a number or date when you have the
error.

--
Regards,
Tom Ogilvy


"excelnut1954" wrote in message
oups.com...
Thanks for the responses. What I'm getting is a Type Mis Match error.
What I was trying to do is to replace this line
Do Until IsEmpty(ActiveCell.Value)
with the one I have above. I inserted a line to sort the list by date,
with the older records at the top. I was just trying to see if I could
save a bit of time having it read only part of the list, instead of
having to read all the 600 records.

Anyway, the original works fine. So, I don't want to spend too much
time on it.
At this point, I'm more interested in why it didn't work, for future
reference. I haven't yet put equations in any of my Do Until commands,
so I thought I had the syntax wrong. Obviously there's something else
at play on why the original line works ok in the macro, but not the new
line.
Thanks
J.O.
Tom Ogilvy wrote:
Sub ABC()
Range("A3").Select

Do Until Range("Current_Date").Value - ActiveCell.Value < 361
ActiveCell.Offset(1, 0).Select
Loop
End Sub

worked fine for me. It stopped on 10/25/2005

--
Regards,
Tom Ogilvy



"excelnut1954" wrote:

Can someone please tell me what is wrong with this command?

Do Until Range("Current_Date").Value - ActiveCell.Value < 361

I tried to add at the end,

Do Until Range("Current_Date").Value - ActiveCell.Value < 361 = True

but it still errors out.

Any suggestions? I've browsed examples here, and couldn't find anything
similar to what I'm doing.
Thanks,
J.O.







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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com