Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
I need to add "8" to the total amount in a cell automatically on the 1st of
every month. I understand I can use the OnTime function for this if excel is running at the time that I set. If Excel is not running at that time, can I set it up to enter that digit the first time I open Excel after the 1st of the month? I am a beginner at VB, so I really need to be walked through this. Thanks a lot. |
#2
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Try this
Private Sub Workbook_Open() Dim dte As Date Dim nMonth As Long On Error Resume Next dte = Evaluate(ThisWorkbook.Names("date_stored").RefersT o) On Error GoTo 0 If dte = 0 Or Month(dte) < Month(Date) Then Worksheets("Sheet1").Range("A1").Value = _ Worksheets("Sheet1").Range("A1").Value + 8 ThisWorkbook.Names.Add Name:="date_stored", RefersTo:=Date ThisWorkbook.Names("date_stored").Visible = False End If End Sub 'This is workbook event code. 'To input this code, right click on the Excel icon on the worksheet '(or next to the File menu if you maximise your workbooks), 'select View Code from the menu, and paste the code -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "SoupNazi" wrote in message ... I need to add "8" to the total amount in a cell automatically on the 1st of every month. I understand I can use the OnTime function for this if excel is running at the time that I set. If Excel is not running at that time, can I set it up to enter that digit the first time I open Excel after the 1st of the month? I am a beginner at VB, so I really need to be walked through this. Thanks a lot. |
#3
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Bob, This seemed to work at first because it immediately added 8 to cell A1
the first time I reopened the workbook. But the cell I needed this in was AB15 so I changed the two references of A1 to AB15. Nothing gets added to AB15 now when I open the workbook. Could it be because the code is telling it to only do this once a month? "Bob Phillips" wrote: Try this Private Sub Workbook_Open() Dim dte As Date Dim nMonth As Long On Error Resume Next dte = Evaluate(ThisWorkbook.Names("date_stored").RefersT o) On Error GoTo 0 If dte = 0 Or Month(dte) < Month(Date) Then Worksheets("Sheet1").Range("A1").Value = _ Worksheets("Sheet1").Range("A1").Value + 8 ThisWorkbook.Names.Add Name:="date_stored", RefersTo:=Date ThisWorkbook.Names("date_stored").Visible = False End If End Sub 'This is workbook event code. 'To input this code, right click on the Excel icon on the worksheet '(or next to the File menu if you maximise your workbooks), 'select View Code from the menu, and paste the code -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "SoupNazi" wrote in message ... I need to add "8" to the total amount in a cell automatically on the 1st of every month. I understand I can use the OnTime function for this if excel is running at the time that I set. If Excel is not running at that time, can I set it up to enter that digit the first time I open Excel after the 1st of the month? I am a beginner at VB, so I really need to be walked through this. Thanks a lot. |
#4
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Exactly. That it is how I read your request. It won't add it again until you
open the workbook in May. -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "SoupNazi" wrote in message ... Bob, This seemed to work at first because it immediately added 8 to cell A1 the first time I reopened the workbook. But the cell I needed this in was AB15 so I changed the two references of A1 to AB15. Nothing gets added to AB15 now when I open the workbook. Could it be because the code is telling it to only do this once a month? "Bob Phillips" wrote: Try this Private Sub Workbook_Open() Dim dte As Date Dim nMonth As Long On Error Resume Next dte = Evaluate(ThisWorkbook.Names("date_stored").RefersT o) On Error GoTo 0 If dte = 0 Or Month(dte) < Month(Date) Then Worksheets("Sheet1").Range("A1").Value = _ Worksheets("Sheet1").Range("A1").Value + 8 ThisWorkbook.Names.Add Name:="date_stored", RefersTo:=Date ThisWorkbook.Names("date_stored").Visible = False End If End Sub 'This is workbook event code. 'To input this code, right click on the Excel icon on the worksheet '(or next to the File menu if you maximise your workbooks), 'select View Code from the menu, and paste the code -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "SoupNazi" wrote in message ... I need to add "8" to the total amount in a cell automatically on the 1st of every month. I understand I can use the OnTime function for this if excel is running at the time that I set. If Excel is not running at that time, can I set it up to enter that digit the first time I open Excel after the 1st of the month? I am a beginner at VB, so I really need to be walked through this. Thanks a lot. |
#5
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Perfect. Thats just what I need I need it to do. Very impressive, Bob. Thanks
a bunch. "Bob Phillips" wrote: Exactly. That it is how I read your request. It won't add it again until you open the workbook in May. -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "SoupNazi" wrote in message ... Bob, This seemed to work at first because it immediately added 8 to cell A1 the first time I reopened the workbook. But the cell I needed this in was AB15 so I changed the two references of A1 to AB15. Nothing gets added to AB15 now when I open the workbook. Could it be because the code is telling it to only do this once a month? "Bob Phillips" wrote: Try this Private Sub Workbook_Open() Dim dte As Date Dim nMonth As Long On Error Resume Next dte = Evaluate(ThisWorkbook.Names("date_stored").RefersT o) On Error GoTo 0 If dte = 0 Or Month(dte) < Month(Date) Then Worksheets("Sheet1").Range("A1").Value = _ Worksheets("Sheet1").Range("A1").Value + 8 ThisWorkbook.Names.Add Name:="date_stored", RefersTo:=Date ThisWorkbook.Names("date_stored").Visible = False End If End Sub 'This is workbook event code. 'To input this code, right click on the Excel icon on the worksheet '(or next to the File menu if you maximise your workbooks), 'select View Code from the menu, and paste the code -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "SoupNazi" wrote in message ... I need to add "8" to the total amount in a cell automatically on the 1st of every month. I understand I can use the OnTime function for this if excel is running at the time that I set. If Excel is not running at that time, can I set it up to enter that digit the first time I open Excel after the 1st of the month? I am a beginner at VB, so I really need to be walked through this. Thanks a lot. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Help!!! Enter "7" in a cell and Excel changes the "7" to "11" immediately!!! | Excel Discussion (Misc queries) | |||
cannot use "Create List" and "Share Workbook" same time | Excel Discussion (Misc queries) | |||
Make "Edit" mode default, rather than "Enter"? | Excel Discussion (Misc queries) | |||
Macro to concatenate into "B1" B2 thru B"x" based on new data in "Col A" | Excel Discussion (Misc queries) | |||
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next | New Users to Excel |