Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
On the last day of each month, insert a static value
I am trying to create a master accrued leave workbook.
I want an action to take place on the last day of each month. That action is to insert a value of "14". |
#2
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
On the last day of each month, insert a static value
Dean
You don't provide what you want to happen when the day of the month is NOT the last day of the month. You also don't say where you want the "14" inserted. I assumed you want nothing to happen if the day is not the last day of the month, and you want the "14" inserted in A1 of a sheet named "TheSheetName". The following macro will do the above. Note that this macro is a Workbook_Open macro and must be placed in the Workbook module. To do this, open the file in which you want this to happen. Right-click on the Excel icon immediately to the left of the "File" in the menu at the top of your sheet, select View Code, and paste this macro into that module. X-out of that module (click on the "X" in the top right corner of the module) to return to your worksheet. This macro will run every time the file is opened. It checks the system date and if the day of the system date is the last day of the current month, it enters "14" in A1 of the "TheSheetName" sheet. Watch out for line wrapping in this message. Expand this message to full screen to see the macro properly. You probably want more than this so post back. HTH Otto Private Sub Workbook_Open() If Day(Date) = Day(DateSerial(Year(Date), Month(Date) + 1, 1) - 1) Then _ Sheets("TheSheetName").Range("A1") = 14 End Sub "Dean" wrote in message ... I am trying to create a master accrued leave workbook. I want an action to take place on the last day of each month. That action is to insert a value of "14". |
#3
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
On the last day of each month, insert a static value
I received a Compile Error, Syntax error.
I changed the TheSheetName to the actual sheet name and I changed the cell name to H7. At first I left the double-quotes in, then I took it out. Both times the same error (Compile Error, Syntax Error) appeared. "Otto Moehrbach" wrote: Dean You don't provide what you want to happen when the day of the month is NOT the last day of the month. You also don't say where you want the "14" inserted. I assumed you want nothing to happen if the day is not the last day of the month, and you want the "14" inserted in A1 of a sheet named "TheSheetName". The following macro will do the above. Note that this macro is a Workbook_Open macro and must be placed in the Workbook module. To do this, open the file in which you want this to happen. Right-click on the Excel icon immediately to the left of the "File" in the menu at the top of your sheet, select View Code, and paste this macro into that module. X-out of that module (click on the "X" in the top right corner of the module) to return to your worksheet. This macro will run every time the file is opened. It checks the system date and if the day of the system date is the last day of the current month, it enters "14" in A1 of the "TheSheetName" sheet. Watch out for line wrapping in this message. Expand this message to full screen to see the macro properly. You probably want more than this so post back. HTH Otto Private Sub Workbook_Open() If Day(Date) = Day(DateSerial(Year(Date), Month(Date) + 1, 1) - 1) Then _ Sheets("TheSheetName").Range("A1") = 14 End Sub "Dean" wrote in message ... I am trying to create a master accrued leave workbook. I want an action to take place on the last day of each month. That action is to insert a value of "14". |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Help!!! Vlookup!! | Excel Worksheet Functions | |||
how do I insert the current time (static) and date in a cell? | Excel Discussion (Misc queries) | |||
How to extract month number from month name | Excel Discussion (Misc queries) | |||
Challenging Charting | Charts and Charting in Excel | |||
Insert Month and Year in my worksheet | Excel Worksheet Functions |