Wrox Programmer Forums
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 29th, 2007, 02:50 PM
Registered User
 
Join Date: Jul 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Argument not Optional

Hi all,

I am fairly new to VBA and have the following problem:

I have the following sub:

Code:
Public Sub AllocateLinks()
    ...
End Bub
This routing is part of the worksheet wsTurns and I call it as:

Code:
Private Sub btnAssignSections_Click()
    wsTurns.AllocateLinks
End Sub
This however causes an Argument not Optional error message which I do not understand.

Thanks for all help,

Hans


 
Old July 29th, 2007, 04:52 PM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hans,

"Argument Not Optional" error is normally thrown when a method requires parameters.

Are you sure there are no parameters for the AllocateLinks Sub??

I am also assuming "wsTurns" is an actual Worksheet, not Worksheets (Collection) Object??
If it is actually a Worksheets Object, then this may cause the error.

Regards,
Rob

<center>"Nothing can stop the man with the right mental attitude from achieving his goal;
nothing on earth can help the man with the wrong mental attitude".

Thomas Jefferson</center>
 
Old July 30th, 2007, 04:18 PM
Registered User
 
Join Date: Jul 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am sure there is no argument required by the function. wsTurns is a worksheet object not a collection.

Cheers,

Az.

 
Old July 31st, 2007, 03:40 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
Default

Does the error occur at compilation or run-time?

Regards,
Rob

<center>"Nothing can stop the man with the right mental attitude from achieving his goal;
nothing on earth can help the man with the wrong mental attitude".

Thomas Jefferson</center>
 
Old August 1st, 2007, 12:49 AM
Registered User
 
Join Date: Jul 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The problem occurs at run time.

Cheers,

Az

 
Old August 1st, 2007, 02:53 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
Default

What line does the error occur on?? Step through the program at run time to see where it falls over.

When you find the line that is causing the problem. Examine each of the objects to see where it is going wrong.

Regards,
Rob

<center>"Nothing can stop the man with the right mental attitude from achieving his goal;
nothing on earth can help the man with the wrong mental attitude".

Thomas Jefferson</center>





Similar Threads
Thread Thread Starter Forum Replies Last Post
Alternative to optional parameters in C# asptwodev BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 5 November 12th, 2007 03:47 AM
Optional prameters and C#? NewTitle2007 BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 2 August 5th, 2007 12:17 PM
compile error: argument not optional loverman210 Beginning VB 6 3 June 8th, 2007 07:59 AM
Error: Argument not optional toshesh Excel VBA 10 January 20th, 2006 10:57 AM
optional where in stored proc david_ste SQL Server ASP 2 October 27th, 2005 07:16 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.