Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default NEWBIE needs BIG help with Macro

Thanks so much in advance for your help. I'm very new to this stuff,
so I probably won't explain myself very well. I'm thinking a macro is
what I need, but I'm not sure.

A3 is the current date.
L9 is the current number of mutual fund units that a client owns
G9 is the amount of money the client invests into the fund every month
on the 5th.
M9 is the current price of the mutual fund.

I need a trigger that will update L9 on the 5th of each month giving
me the new unit total based on the fact that the amount in G9 has now
been invested into the fund.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default NEWBIE needs BIG help with Macro

Hi

You could try something like the code below which should do what you
want. It will pass the current date to a string variable then split
that string into the following sections

MyDay = the numeric value of the day i.e. the 5th
DayName = the three letter day abbreviation

It will then check MyDay every time the workbook is opened if the
value returned is
5 then the 5th is a weekday presuming you will only be opening it
during the five day working week
6 then the 5th may have been a Sunday so check DayName if it is "Mon"
then the 5th was a Sunday run the code if DayName is not "Mon" do
nothing
7 then the 5th may have been a Saturday so check DayName if it is
"Mon" then the 5th was a Saturday run the code if DayName is not "Mon"
do nothing

In the workbook module
Option Explicit
Dim MyDate, DayName As String 'Declare your variables
Dim MyDay As Integer

Private Sub Workbook_Open()

MyDate = Format(Date, "DDD DD/MMM/YYYY") 'Pass the full date to a
string

'MyDate = "Sat 06/04/2007" 'to test this sub, comment the line above
'and remove the comment mark from before MyDate, test your variations

Sheets(1).Activate 'Select the worksheet you want to work with

[A3].Value = Right(MyDate, 11) 'Put only the DD/MMM/YYYY to cell A3

MyDay = Mid(MyDate, 5, 2) 'Pass the numeric value of the day to an
integer

DayName = Left(MyDate, 3) 'Pass the day name to a string

Select Case MyDay 'Set to check the date

Case "5" '5th falls on a week day
[L9].Value = [L9].Value - [G9].Value

Case "6" '5th falls on a Sunday
If DayName = "Mon" Then
[L9].Value = [L9].Value - [G9].Value
End If

Case "7" '5th falls on a Saturday
If DayName = "Mon" Then
[L9].Value = [L9].Value - [G9].Value
End If

End Select

End Sub

hope this is of some help to you

S

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
Macro Newbie Wild Packet Excel Programming 2 November 25th 06 05:28 PM
Newbie - Help with a macro Mike Basden Excel Programming 4 February 9th 06 12:36 AM
Newbie needs macro help please Keith[_15_] Excel Programming 4 December 3rd 04 10:39 PM
Macro newbie VB Newbie Excel Programming 3 November 12th 04 07:08 AM
Macro Help for Newbie Phil Excel Programming 2 October 15th 03 04:57 AM


All times are GMT +1. The time now is 11:29 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"