Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Problem using VBA for the Networkdays function

I am using VBA in MS project to enter information into Excel 2003. It
creates an instance and enters various dates. However if I put the
Newworkdays function into a cell (e.g. xlApp.range("D6").value =
"=networkdays(rc[-3],rc[-2])" where D4 and D5 are recognised dates I get the
#NAME? error message. The Add-ins for the Analysis toolpak have been ticked.


I tried running code to turn the analysis toolpak off and then on
programatically but still the same error message

Any ideas how this can be fixed?

Many thanks

James
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,440
Default Problem using VBA for the Networkdays function

Hi James,

Range("D6").FormulaR1C1 = "=networkdays(rc[-3],rc[-2])"

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

" wrote in message
...
|I am using VBA in MS project to enter information into Excel 2003. It
| creates an instance and enters various dates. However if I put the
| Newworkdays function into a cell (e.g. xlApp.range("D6").value =
| "=networkdays(rc[-3],rc[-2])" where D4 and D5 are recognised dates I get the
| #NAME? error message. The Add-ins for the Analysis toolpak have been ticked.
|
|
| I tried running code to turn the analysis toolpak off and then on
| programatically but still the same error message
|
| Any ideas how this can be fixed?
|
| Many thanks
|
| James


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Problem using VBA for the Networkdays function

Sorry Niek doesn't work. In my experience .value and .formular1c1 work the
same

James

" wrote:

I am using VBA in MS project to enter information into Excel 2003. It
creates an instance and enters various dates. However if I put the
Newworkdays function into a cell (e.g. xlApp.range("D6").value =
"=networkdays(rc[-3],rc[-2])" where D4 and D5 are recognised dates I get the
#NAME? error message. The Add-ins for the Analysis toolpak have been ticked.


I tried running code to turn the analysis toolpak off and then on
programatically but still the same error message

Any ideas how this can be fixed?

Many thanks

James

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,440
Default Problem using VBA for the Networkdays function

Be aware that your formula is not referring to D4 and D5, but to A6 and B6. Are any of them #NAME?
I assume that you have Analysis Toolpak ticked in your worksheet Add-ins menu, not (just) VBA

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

" wrote in message
...
| Sorry Niek doesn't work. In my experience .value and .formular1c1 work the
| same
|
| James
|
| " wrote:
|
| I am using VBA in MS project to enter information into Excel 2003. It
| creates an instance and enters various dates. However if I put the
| Newworkdays function into a cell (e.g. xlApp.range("D6").value =
| "=networkdays(rc[-3],rc[-2])" where D4 and D5 are recognised dates I get the
| #NAME? error message. The Add-ins for the Analysis toolpak have been ticked.
|
|
| I tried running code to turn the analysis toolpak off and then on
| programatically but still the same error message
|
| Any ideas how this can be fixed?
|
| Many thanks
|
| James


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Problem using VBA for the Networkdays function

it is D4 and D5. More importantly the function name is not in capitals
implying that XL can't see the function name. The Analysis toolpak has been
ticked in the Add-ins

Try it creating a simple macro in Word - I can give you the code if you want


"Niek Otten" wrote:

Be aware that your formula is not referring to D4 and D5, but to A6 and B6. Are any of them #NAME?
I assume that you have Analysis Toolpak ticked in your worksheet Add-ins menu, not (just) VBA

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

" wrote in message
...
| Sorry Niek doesn't work. In my experience .value and .formular1c1 work the
| same
|
| James
|
| " wrote:
|
| I am using VBA in MS project to enter information into Excel 2003. It
| creates an instance and enters various dates. However if I put the
| Newworkdays function into a cell (e.g. xlApp.range("D6").value =
| "=networkdays(rc[-3],rc[-2])" where D4 and D5 are recognised dates I get the
| #NAME? error message. The Add-ins for the Analysis toolpak have been ticked.
|
|
| I tried running code to turn the analysis toolpak off and then on
| programatically but still the same error message
|
| Any ideas how this can be fixed?
|
| Many thanks
|
| James





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Problem using VBA for the Networkdays function

James,

When you use Excel via automation, the addins do not get loaded, so you get
the error.

Force the load like so


xlApp.AddIns("Analysis ToolPak").Installed = False
xlApp.AddIns("Analysis ToolPak").Installed = True
xlApp.Range("D6").Value = "=networkdays(rc[-3],rc[-2])"

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"
wrote in message ...
it is D4 and D5. More importantly the function name is not in capitals
implying that XL can't see the function name. The Analysis toolpak has

been
ticked in the Add-ins

Try it creating a simple macro in Word - I can give you the code if you

want


"Niek Otten" wrote:

Be aware that your formula is not referring to D4 and D5, but to A6 and

B6. Are any of them #NAME?
I assume that you have Analysis Toolpak ticked in your worksheet Add-ins

menu, not (just) VBA

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"

wrote in message
...
| Sorry Niek doesn't work. In my experience .value and .formular1c1

work the
| same
|
| James
|
| " wrote:
|
| I am using VBA in MS project to enter information into Excel 2003.

It
| creates an instance and enters various dates. However if I put the
| Newworkdays function into a cell (e.g. xlApp.range("D6").value =
| "=networkdays(rc[-3],rc[-2])" where D4 and D5 are recognised dates I

get the
| #NAME? error message. The Add-ins for the Analysis toolpak have

been ticked.
|
|
| I tried running code to turn the analysis toolpak off and then on
| programatically but still the same error message
|
| Any ideas how this can be fixed?
|
| Many thanks
|
| James





  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,440
Default Problem using VBA for the Networkdays function

Hi James,

And after you've sorted that out, check the cell references in your formula in the worksheet; it IS A6 and B6 (Columns -3 and -2,
not Rows)

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"Bob Phillips" wrote in message ...
| James,
|
| When you use Excel via automation, the addins do not get loaded, so you get
| the error.
|
| Force the load like so
|
|
| xlApp.AddIns("Analysis ToolPak").Installed = False
| xlApp.AddIns("Analysis ToolPak").Installed = True
| xlApp.Range("D6").Value = "=networkdays(rc[-3],rc[-2])"
|
| --
| HTH
|
| Bob Phillips
|
| (replace somewhere in email address with gmail if mailing direct)
|
| "
| wrote in message ...
| it is D4 and D5. More importantly the function name is not in capitals
| implying that XL can't see the function name. The Analysis toolpak has
| been
| ticked in the Add-ins
|
| Try it creating a simple macro in Word - I can give you the code if you
| want
|
|
| "Niek Otten" wrote:
|
| Be aware that your formula is not referring to D4 and D5, but to A6 and
| B6. Are any of them #NAME?
| I assume that you have Analysis Toolpak ticked in your worksheet Add-ins
| menu, not (just) VBA
|
| --
| Kind regards,
|
| Niek Otten
| Microsoft MVP - Excel
|
| "
| wrote in message
| ...
| | Sorry Niek doesn't work. In my experience .value and .formular1c1
| work the
| | same
| |
| | James
| |
| | " wrote:
| |
| | I am using VBA in MS project to enter information into Excel 2003.
| It
| | creates an instance and enters various dates. However if I put the
| | Newworkdays function into a cell (e.g. xlApp.range("D6").value =
| | "=networkdays(rc[-3],rc[-2])" where D4 and D5 are recognised dates I
| get the
| | #NAME? error message. The Add-ins for the Analysis toolpak have
| been ticked.
| |
| |
| | I tried running code to turn the analysis toolpak off and then on
| | programatically but still the same error message
| |
| | Any ideas how this can be fixed?
| |
| | Many thanks
| |
| | James
|
|
|
|
|


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Networkdays function problem Bright Excel Discussion (Misc queries) 0 January 2nd 08 03:17 AM
NETWORKDAYS problem Rick, United Kingdom Excel Programming 2 August 21st 05 10:00 PM
NETWORKDAYS function problem Arvi Laanemets Excel Worksheet Functions 5 April 19th 05 08:10 AM
Networkdays problem JamesDMartin Excel Worksheet Functions 3 March 31st 05 11:26 PM
Nested IF Function, Date Comparing, and NetworkDays Function carl Excel Worksheet Functions 2 December 29th 04 09:57 PM


All times are GMT +1. The time now is 01:28 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"