Exell problems

Ask the few things google does not know

Moderator: Dictators in Training

Exell problems

Postby kaharthemad » Fri Sep 02, 2005 12:51 pm

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?
Image
User avatar
kaharthemad
NT Traveller
NT Traveller
 
Posts: 3768
Joined: Sat Mar 27, 2004 8:47 am
Location: Somewhere South of Disorder

Postby Menlaan » Fri Sep 02, 2005 1:02 pm

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
User avatar
Menlaan
NT Patron
NT Patron
 
Posts: 1851
Joined: Tue Mar 09, 2004 3:11 pm
Location: NY

Postby Menlaan » Fri Sep 02, 2005 1:18 pm

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
User avatar
Menlaan
NT Patron
NT Patron
 
Posts: 1851
Joined: Tue Mar 09, 2004 3:11 pm
Location: NY

Postby Menlaan » Fri Sep 02, 2005 1:29 pm

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
User avatar
Menlaan
NT Patron
NT Patron
 
Posts: 1851
Joined: Tue Mar 09, 2004 3:11 pm
Location: NY

Postby Menlaan » Tue Sep 06, 2005 9:22 am

Kahar, how'd this work out?

Menlaan
User avatar
Menlaan
NT Patron
NT Patron
 
Posts: 1851
Joined: Tue Mar 09, 2004 3:11 pm
Location: NY

Postby kaharthemad » Tue Sep 06, 2005 9:29 am

just got back into the office. so I am trying it out now
sorry was busy this weekend and did not have time.
Image
User avatar
kaharthemad
NT Traveller
NT Traveller
 
Posts: 3768
Joined: Sat Mar 27, 2004 8:47 am
Location: Somewhere South of Disorder


Return to Tech Support

Who is online

Users browsing this forum: No registered users and 3 guests