Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default NETWORKDAYS Function in Macro

If we have dates in A1 and A2, we can use the NETWORKDAYS
function in Excel to get a net workday count.
=NETWORKDAYS(A1,A2)

Is there a way to get this result in a macro?

TIA.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default NETWORKDAYS Function in Macro

Set a reference to the Analysis toolpak, APTVBAEN.XLA (lower-case on my
machine) and then just call it, like so

?networkdays(date-100,date-10)
--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Ken" wrote in message
...
If we have dates in A1 and A2, we can use the NETWORKDAYS
function in Excel to get a net workday count.
=NETWORKDAYS(A1,A2)

Is there a way to get this result in a macro?

TIA.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default NETWORKDAYS Function in Macro

Sorry, Bob, but you lost me here.
How/where do we set a reference to the Analysis toolpak?
What goes into the macro code?
Thanks for your patience.

-----Original Message-----
Set a reference to the Analysis toolpak, APTVBAEN.XLA

(lower-case on my
machine) and then just call it, like so

?networkdays(date-100,date-10)
--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Ken" wrote in

message
...
If we have dates in A1 and A2, we can use the

NETWORKDAYS
function in Excel to get a net workday count.
=NETWORKDAYS(A1,A2)

Is there a way to get this result in a macro?

TIA.



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default NETWORKDAYS Function in Macro

Ken,

In Excel, go to the Tools menu, choose Add-Ins, and the put a
check next to "Analysis Tool Pak - VBA". Then, go the VBA
editor, choose the Tools menu, then References. There, put a
check next to "ATPVBAEN.XLA".


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Ken" wrote in message
...
Sorry, Bob, but you lost me here.
How/where do we set a reference to the Analysis toolpak?
What goes into the macro code?
Thanks for your patience.

-----Original Message-----
Set a reference to the Analysis toolpak, APTVBAEN.XLA

(lower-case on my
machine) and then just call it, like so

?networkdays(date-100,date-10)
--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Ken" wrote in

message
...
If we have dates in A1 and A2, we can use the

NETWORKDAYS
function in Excel to get a net workday count.
=NETWORKDAYS(A1,A2)

Is there a way to get this result in a macro?

TIA.



.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default NETWORKDAYS Function in Macro

So, with dates in A1 and A2 would the code to put the
networkdays in A3 be:

Sub Test()
Dim count As Integer
wks.Cells(3, 1).Value = networkdays(A2, A1)
End Sub

I am coding it wrong because it doesn't seem to work?

-----Original Message-----
Ken,

In Excel, go to the Tools menu, choose Add-Ins, and the

put a
check next to "Analysis Tool Pak - VBA". Then, go the VBA
editor, choose the Tools menu, then References. There,

put a
check next to "ATPVBAEN.XLA".


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Ken" wrote in

message
...
Sorry, Bob, but you lost me here.
How/where do we set a reference to the Analysis toolpak?
What goes into the macro code?
Thanks for your patience.

-----Original Message-----
Set a reference to the Analysis toolpak, APTVBAEN.XLA

(lower-case on my
machine) and then just call it, like so

?networkdays(date-100,date-10)
--

HTH

Bob Phillips
... looking out across Poole Harbour to the

Purbecks
(remove nothere from the email address if mailing

direct)

"Ken" wrote in

message
...
If we have dates in A1 and A2, we can use the

NETWORKDAYS
function in Excel to get a net workday count.
=NETWORKDAYS(A1,A2)

Is there a way to get this result in a macro?

TIA.


.



.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default NETWORKDAYS Function in Macro

Ken,

Use

wks.Cells(3, 1).Value = networkdays(Range("A2"),Range("A1"))


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Ken" wrote in message
...
So, with dates in A1 and A2 would the code to put the
networkdays in A3 be:

Sub Test()
Dim count As Integer
wks.Cells(3, 1).Value = networkdays(A2, A1)
End Sub

I am coding it wrong because it doesn't seem to work?

-----Original Message-----
Ken,

In Excel, go to the Tools menu, choose Add-Ins, and the

put a
check next to "Analysis Tool Pak - VBA". Then, go the VBA
editor, choose the Tools menu, then References. There,

put a
check next to "ATPVBAEN.XLA".


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Ken" wrote in

message
...
Sorry, Bob, but you lost me here.
How/where do we set a reference to the Analysis toolpak?
What goes into the macro code?
Thanks for your patience.

-----Original Message-----
Set a reference to the Analysis toolpak, APTVBAEN.XLA
(lower-case on my
machine) and then just call it, like so

?networkdays(date-100,date-10)
--

HTH

Bob Phillips
... looking out across Poole Harbour to the

Purbecks
(remove nothere from the email address if mailing

direct)

"Ken" wrote in
message
...
If we have dates in A1 and A2, we can use the
NETWORKDAYS
function in Excel to get a net workday count.
=NETWORKDAYS(A1,A2)

Is there a way to get this result in a macro?

TIA.


.



.



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default NETWORKDAYS Function in Macro

or you could use

Application.Evaluate("NETWORKDAYS(A2,A1)")

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Chip Pearson" wrote in message
...
Ken,

Use

wks.Cells(3, 1).Value = networkdays(Range("A2"),Range("A1"))


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Ken" wrote in message
...
So, with dates in A1 and A2 would the code to put the
networkdays in A3 be:

Sub Test()
Dim count As Integer
wks.Cells(3, 1).Value = networkdays(A2, A1)
End Sub

I am coding it wrong because it doesn't seem to work?

-----Original Message-----
Ken,

In Excel, go to the Tools menu, choose Add-Ins, and the

put a
check next to "Analysis Tool Pak - VBA". Then, go the VBA
editor, choose the Tools menu, then References. There,

put a
check next to "ATPVBAEN.XLA".


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Ken" wrote in

message
...
Sorry, Bob, but you lost me here.
How/where do we set a reference to the Analysis toolpak?
What goes into the macro code?
Thanks for your patience.

-----Original Message-----
Set a reference to the Analysis toolpak, APTVBAEN.XLA
(lower-case on my
machine) and then just call it, like so

?networkdays(date-100,date-10)
--

HTH

Bob Phillips
... looking out across Poole Harbour to the

Purbecks
(remove nothere from the email address if mailing

direct)

"Ken" wrote in
message
...
If we have dates in A1 and A2, we can use the
NETWORKDAYS
function in Excel to get a net workday count.
=NETWORKDAYS(A1,A2)

Is there a way to get this result in a macro?

TIA.


.



.





  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default NETWORKDAYS Function in Macro

When I ran it, I got a:

"Run time error '424':
Object Required

error message?

-----Original Message-----
Ken,

Use

wks.Cells(3, 1).Value = networkdays(Range("A2"),Range

("A1"))


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Ken" wrote in

message
...
So, with dates in A1 and A2 would the code to put the
networkdays in A3 be:

Sub Test()
Dim count As Integer
wks.Cells(3, 1).Value = networkdays(A2, A1)
End Sub

I am coding it wrong because it doesn't seem to work?

-----Original Message-----
Ken,

In Excel, go to the Tools menu, choose Add-Ins, and the

put a
check next to "Analysis Tool Pak - VBA". Then, go the

VBA
editor, choose the Tools menu, then References. There,

put a
check next to "ATPVBAEN.XLA".


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Ken" wrote in

message
...
Sorry, Bob, but you lost me here.
How/where do we set a reference to the Analysis

toolpak?
What goes into the macro code?
Thanks for your patience.

-----Original Message-----
Set a reference to the Analysis toolpak,

APTVBAEN.XLA
(lower-case on my
machine) and then just call it, like so

?networkdays(date-100,date-10)
--

HTH

Bob Phillips
... looking out across Poole Harbour to the

Purbecks
(remove nothere from the email address if mailing

direct)

"Ken" wrote in
message
...
If we have dates in A1 and A2, we can use the
NETWORKDAYS
function in Excel to get a net workday count.
=NETWORKDAYS(A1,A2)

Is there a way to get this result in a macro?

TIA.


.



.



.

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default NETWORKDAYS Function in Macro

Did you set the reference as described?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Ken" wrote in message
...
When I ran it, I got a:

"Run time error '424':
Object Required

error message?

-----Original Message-----
Ken,

Use

wks.Cells(3, 1).Value = networkdays(Range("A2"),Range

("A1"))


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Ken" wrote in

message
...
So, with dates in A1 and A2 would the code to put the
networkdays in A3 be:

Sub Test()
Dim count As Integer
wks.Cells(3, 1).Value = networkdays(A2, A1)
End Sub

I am coding it wrong because it doesn't seem to work?

-----Original Message-----
Ken,

In Excel, go to the Tools menu, choose Add-Ins, and the
put a
check next to "Analysis Tool Pak - VBA". Then, go the

VBA
editor, choose the Tools menu, then References. There,
put a
check next to "ATPVBAEN.XLA".


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Ken" wrote in
message
...
Sorry, Bob, but you lost me here.
How/where do we set a reference to the Analysis

toolpak?
What goes into the macro code?
Thanks for your patience.

-----Original Message-----
Set a reference to the Analysis toolpak,

APTVBAEN.XLA
(lower-case on my
machine) and then just call it, like so

?networkdays(date-100,date-10)
--

HTH

Bob Phillips
... looking out across Poole Harbour to the
Purbecks
(remove nothere from the email address if mailing
direct)

"Ken" wrote in
message
...
If we have dates in A1 and A2, we can use the
NETWORKDAYS
function in Excel to get a net workday count.
=NETWORKDAYS(A1,A2)

Is there a way to get this result in a macro?

TIA.


.



.



.



  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default NETWORKDAYS Function in Macro

Yes, although my reference is atpvbaen.xls not
atpvbaen.xla.

Anyway, I entered the following code and got it to work.

Sub Test()
Dim count As Integer
count = Application.Evaluate("NETWORKDAYS(A2,A1)")
Range("A3").Select
ActiveCell.Value = count
End Sub

-----Original Message-----
Did you set the reference as described?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Ken" wrote in

message
...
When I ran it, I got a:

"Run time error '424':
Object Required

error message?

-----Original Message-----
Ken,

Use

wks.Cells(3, 1).Value = networkdays(Range

("A2"),Range
("A1"))


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Ken" wrote in

message
...
So, with dates in A1 and A2 would the code to put the
networkdays in A3 be:

Sub Test()
Dim count As Integer
wks.Cells(3, 1).Value = networkdays(A2, A1)
End Sub

I am coding it wrong because it doesn't seem to work?

-----Original Message-----
Ken,

In Excel, go to the Tools menu, choose Add-Ins, and

the
put a
check next to "Analysis Tool Pak - VBA". Then, go

the
VBA
editor, choose the Tools menu, then References.

There,
put a
check next to "ATPVBAEN.XLA".


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Ken" wrote in
message
...
Sorry, Bob, but you lost me here.
How/where do we set a reference to the Analysis

toolpak?
What goes into the macro code?
Thanks for your patience.

-----Original Message-----
Set a reference to the Analysis toolpak,

APTVBAEN.XLA
(lower-case on my
machine) and then just call it, like so

?networkdays(date-100,date-10)
--

HTH

Bob Phillips
... looking out across Poole Harbour to the
Purbecks
(remove nothere from the email address if mailing
direct)

"Ken"

wrote in
message
...
If we have dates in A1 and A2, we can use the
NETWORKDAYS
function in Excel to get a net workday count.
=NETWORKDAYS(A1,A2)

Is there a way to get this result in a macro?

TIA.


.



.



.



.



  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default NETWORKDAYS Function in Macro

You are right, so is mine. Mine works though<G

Sorry no other ideas at the moment. Have you tried my Evaluate suggestion,
it shouldn't make any difference but you never know.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Ken" wrote in message
...
Yes, although my reference is atpvbaen.xls not
atpvbaen.xla.

Anyway, I entered the following code and got it to work.

Sub Test()
Dim count As Integer
count = Application.Evaluate("NETWORKDAYS(A2,A1)")
Range("A3").Select
ActiveCell.Value = count
End Sub

-----Original Message-----
Did you set the reference as described?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Ken" wrote in

message
...
When I ran it, I got a:

"Run time error '424':
Object Required

error message?

-----Original Message-----
Ken,

Use

wks.Cells(3, 1).Value = networkdays(Range

("A2"),Range
("A1"))


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Ken" wrote in
message
...
So, with dates in A1 and A2 would the code to put the
networkdays in A3 be:

Sub Test()
Dim count As Integer
wks.Cells(3, 1).Value = networkdays(A2, A1)
End Sub

I am coding it wrong because it doesn't seem to work?

-----Original Message-----
Ken,

In Excel, go to the Tools menu, choose Add-Ins, and

the
put a
check next to "Analysis Tool Pak - VBA". Then, go

the
VBA
editor, choose the Tools menu, then References.

There,
put a
check next to "ATPVBAEN.XLA".


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Ken" wrote in
message
...
Sorry, Bob, but you lost me here.
How/where do we set a reference to the Analysis
toolpak?
What goes into the macro code?
Thanks for your patience.

-----Original Message-----
Set a reference to the Analysis toolpak,
APTVBAEN.XLA
(lower-case on my
machine) and then just call it, like so

?networkdays(date-100,date-10)
--

HTH

Bob Phillips
... looking out across Poole Harbour to the
Purbecks
(remove nothere from the email address if mailing
direct)

"Ken"

wrote in
message
...
If we have dates in A1 and A2, we can use the
NETWORKDAYS
function in Excel to get a net workday count.
=NETWORKDAYS(A1,A2)

Is there a way to get this result in a macro?

TIA.


.



.



.



.



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
networkdays function Medo Excel Worksheet Functions 4 December 26th 08 06:08 PM
Networkdays Function Ron Bridgeman Excel Worksheet Functions 11 March 20th 08 08:22 PM
NETWORKDAYS function kippers Excel Discussion (Misc queries) 2 June 19th 07 02:30 PM
Nesting Networkdays function inside and If function Addison Excel Worksheet Functions 2 April 13th 06 08:04 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 05:10 PM.

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

About Us

"It's about Microsoft Excel"