Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 9
Default how to enter data "OnTime", OR when workbook opened

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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10,593
Default how to enter data "OnTime", OR when workbook opened

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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 9
Default how to enter data "OnTime", OR when workbook opened

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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10,593
Default how to enter data "OnTime", OR when workbook opened

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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 9
Default how to enter data "OnTime", OR when workbook opened

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
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
Help!!! Enter "7" in a cell and Excel changes the "7" to "11" immediately!!! [email protected] Excel Discussion (Misc queries) 3 January 5th 07 02:18 PM
cannot use "Create List" and "Share Workbook" same time Devendra Excel Discussion (Misc queries) 0 October 26th 06 06:05 AM
Make "Edit" mode default, rather than "Enter"? Greg Boettcher Excel Discussion (Misc queries) 1 July 27th 06 01:46 AM
Macro to concatenate into "B1" B2 thru B"x" based on new data in "Col A" Dennis Excel Discussion (Misc queries) 0 July 17th 06 02:38 PM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM


All times are GMT +1. The time now is 12:51 PM.

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

About Us

"It's about Microsoft Excel"