Page 1 of 1

Exell problems

Posted: Fri Sep 02, 2005 12:51 pm
by kaharthemad
Here is my problem I need to design a excell spread sheet that when a button is clicked it saves the name of the user is a cell("Name") and adds the date of payday, i.e. the upcomming friday. I have figured out the code to create the date I need just not sure how to add it to the Name. Here is the code I have written so far. example TMcGee02SEPT05


Function Begin()
'function to find Monday based on today's date
Dim mday As Date
mday = Date
Do Until WeekDay(mday) = 2
mday = mday - 1
Loop
Begin = CStr(mday)
End Function
'=============================­======================
Function EndDate()
'function to find Friday based on today's date
Dim mday As Date
mday = Date
Do Until WeekDay(mday) = 6
mday = mday + 1
Loop
EndDate = CStr(mday)
End Function



Any ideas?

Posted: Fri Sep 02, 2005 1:02 pm
by Menlaan
I don't fully understand what you want to do? You just want to append the user's name into a certain cell?

If so, you would just say Range("Name").value = EndDate() + "TMcGee"

Is this what you're looking for? the '+' works as an append.

Menlaan

Posted: Fri Sep 02, 2005 1:18 pm
by Menlaan
Also, you can replace the "TMcGee" with Application.UserName

To create the button, bring up the Forms toolbar and you can drag a button and assign it to your macro.

The macro would look like:

Sub button1()

Range("Name").Value = EndDate() + Application.UserName

End Sub

Posted: Fri Sep 02, 2005 1:29 pm
by Menlaan
Finally, if you want to format your date, you can use this:

Range("Name").Value = Application.UserName + Format(EndDate(), "ddmmmyy")

I've got to take off for a while, but hopefully the answer you're looking for is in one of the posts above. :wink:

Menlaan

Posted: Tue Sep 06, 2005 9:22 am
by Menlaan
Kahar, how'd this work out?

Menlaan

Posted: Tue Sep 06, 2005 9:29 am
by kaharthemad
just got back into the office. so I am trying it out now
sorry was busy this weekend and did not have time.