View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Don Guillett Don Guillett is offline
external usenet poster
 
Posts: 10,124
Default Autocalculate my share balance each month after monthly contribution

Put ALL of this in your ThisWorkbook module. Change sheet2 to your sheet
name. Fire the setwhichmonth to test or reset.

'============
Public whichmonth

Sub setwhichmoth()
whichmonth = 1
End Sub
'=========
Sub workbook_open()
On Error GoTo endit
If Month(Date) whichmonth Then nm = Month(Date)
If DateSerial(Year(Date), nm, 1) = _
Application.Run("ATPVBAEN.xla!Workday", nm - Day(nm), 1) Then
With Sheets("sheet2").Range("k12")
.Value = .Value + 100
End With
whichmonth = Month(Date)
End If
endit:
End Sub
'=======
--
Don Guillett
SalesAid Software

wrote in message
ups.com...
A12 = Microsoft


O12 = the market value of my microsoft shares.
M12 = the number of Microsoft shares I currently own
N12 = the current price of each share.
G12 = the amount of money I invest into Microsoft each month ...
always the same monthly investment
H12 = the day of the month (call it the 1st) that I make the monthly
investment .... always the same day .... unless it is not a business
day

I need a formula or macro that would re-calculate cell M12 after I
make each monthly investment.


Summary.... on May 31st, I owned 4000 Microsoft shares. On the 1st I
bought 100 more. I need M12 to update to 4100 when I run the macro.
Can the macro be programmed to run only once each month?