ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Date entry using a macro (https://www.excelbanter.com/excel-programming/308752-date-entry-using-macro.html)

disco

Date entry using a macro
 
Hey guys,

Have searched the forum and cant find the answer to this one!

I am trying to enter in a date in a cell using a macro; the date needs to be
3 working days before todays date. I thought i could utilise the NETWORKDAYS
function, but cant seem to do it.

Thanks in advance

Dan

GJones

Date entry using a macro
 
Hi Disco;

Use this;

ActiveCell = Date - 3


Thanks,

Greg
-----Original Message-----
Hey guys,

Have searched the forum and cant find the answer to this

one!

I am trying to enter in a date in a cell using a macro;

the date needs to be
3 working days before todays date. I thought i could

utilise the NETWORKDAYS
function, but cant seem to do it.

Thanks in advance

Dan
.


Bob Phillips[_6_]

Date entry using a macro
 
=WORKDAY(TODAY(),-3)

--

HTH

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

"disco" wrote in message
...
Hey guys,

Have searched the forum and cant find the answer to this one!

I am trying to enter in a date in a cell using a macro; the date needs to

be
3 working days before todays date. I thought i could utilise the

NETWORKDAYS
function, but cant seem to do it.

Thanks in advance

Dan




Frank Stone

Date entry using a macro
 
hi
try this:
Sub maccount3()
Dim c As Variant
Dim ctr As Integer
c = Date
ctr = 3
Do While ctr = 1
If Weekday(c) = 1 Then
c = c - 2
Else
ctr = ctr - 1
c = c - 1
End If
Loop
MsgBox "3 Days from now(not counting weekends) is " & c
c.Value = Range("mycell").Value
End Sub

-----Original Message-----
Hey guys,

Have searched the forum and cant find the answer to this

one!

I am trying to enter in a date in a cell using a macro;

the date needs to be
3 working days before todays date. I thought i could

utilise the NETWORKDAYS
function, but cant seem to do it.

Thanks in advance

Dan
.


Bob Phillips[_6_]

Date entry using a macro
 
Yes it is, it is part of the Analysis Toolpak, just like Networkdays

--

HTH

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

"disco" wrote in message
...
thanks guys, much appreciated! used if statements and the weekday function

in
the end, as workday is not available in VBA!!

thanks again

"Frank Stone" wrote:

hi
try this:
Sub maccount3()
Dim c As Variant
Dim ctr As Integer
c = Date
ctr = 3
Do While ctr = 1
If Weekday(c) = 1 Then
c = c - 2
Else
ctr = ctr - 1
c = c - 1
End If
Loop
MsgBox "3 Days from now(not counting weekends) is " & c
c.Value = Range("mycell").Value
End Sub

-----Original Message-----
Hey guys,

Have searched the forum and cant find the answer to this

one!

I am trying to enter in a date in a cell using a macro;

the date needs to be
3 working days before todays date. I thought i could

utilise the NETWORKDAYS
function, but cant seem to do it.

Thanks in advance

Dan
.






All times are GMT +1. The time now is 08:13 PM.

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