PC Review


Reply
Thread Tools Rate Thread

Do Until syntax problem

 
 
excelnut1954
Guest
Posts: n/a
 
      20th Oct 2006
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.

 
Reply With Quote
 
 
 
 
dolivastro@gmail.com
Guest
Posts: n/a
 
      20th Oct 2006
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.


 
Reply With Quote
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      20th Oct 2006
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.
>
>

 
Reply With Quote
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      20th Oct 2006
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.
>
>

 
Reply With Quote
 
excelnut1954
Guest
Posts: n/a
 
      20th Oct 2006
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.
> >
> >


 
Reply With Quote
 
Tom Ogilvy
Guest
Posts: n/a
 
      21st Oct 2006
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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.
>> >
>> >

>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with Syntax? MurrayBarn Microsoft Excel Worksheet Functions 8 12th Jun 2009 01:45 PM
For-each syntax problem excelnut1954 Microsoft Excel Programming 5 10th May 2007 03:09 PM
syntax problem with gpresult - and problem with Group Pol in gener =?Utf-8?B?Sm9yZGFu?= Microsoft Windows 2000 Group Policy 1 12th Apr 2007 08:32 PM
Problem with syntax..HELP =?Utf-8?B?VGltOjouLg==?= Microsoft ASP .NET 3 19th May 2004 06:31 PM
syntax problem David Hunt Microsoft Access VBA Modules 3 17th Oct 2003 06:20 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:43 PM.