Automatically adding a Date to Named Date Range Each Day - Excel 2003

ajay_gajree

Well-known Member
Joined
Jul 16, 2011
Messages
518
Hi,

I have a Named Date Range in my Workbook, is there an easy VBA code to add a new (Previous Business Day) to the list each day,

I could add them in advance, but I use the range as a Data Validation List and would like to avoid showing the user future dates,

Any advise or a point in the right direction would be appreciated!

Best Regards

Ajay
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Are the cells always going to be the same?

And do you mean name the range and add a date to the name?

<font face=Courier New><SPAN style="color:#00007F">Sub</SPAN> nameMe()<br>Range("C1:C10").Name = ("Castle_" & Format(Date, "dd_mmm_yyyy"))<br><br><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>
 
Upvote 0
The range is named, so for Example I have in the Range

01/08/11
02/08/11
03/08/11
04/08/11
05/08/11

I wish to add 08/08/11 today without going to the Range as it is on a Hidden Sheet in My Dashboard.

Just trying to automate if possible, perhaps with a macro assigned to a Button to add the previous working day to my range.
 
Upvote 0
Try this

<font face=Courier New><SPAN style="color:#00007F">Sub</SPAN> nameMe1()<br><SPAN style="color:#007F00">'Move into a Cell in the range</SPAN><br>Range("C2").Select<br>Selection.End(xlDown).Select <SPAN style="color:#007F00">'Using xlDown to move to the last cell</SPAN><br>ActiveCell.Offset(1, 0) = <SPAN style="color:#00007F">Date</SPAN> <SPAN style="color:#007F00">'Off setting 1 Cell and Adding Date</SPAN><br>ActiveCell.CurrentRegion.Name = "List" <SPAN style="color:#007F00">'Finally Selecting cells and assigning it a name</SPAN><br><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>
 
Upvote 0
Is it possible to use Workday instead of date?

I tried this in the code you provided, and it failed, is there a different name for this?
 
Upvote 0
You should be able to do what you want in Excel, just by using the WORKDAY function (it is part of the Analysis Tool-Pak, make sure it is activeated by going to Tools | Add-ins and checking "Analysis Toolpak").

Also check the VBA one as well
 
Upvote 0

Forum statistics

Threads
1,224,596
Messages
6,179,807
Members
452,944
Latest member
2558216095

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top