Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Calendar inhance

Anyone please help,

How to create a calendar using userform. I mean when user click on the
prefered date, it automatically display into a cell e.g. user click on 1,2,4
and 7 in the month of December, 2005 then click ok, the output display in
sheet1 cell (d5) as 1,2,4 and 7 Dec, 2005,

Thanks in advance.
Jaemun.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Calendar inhance

Hi Jaemun,
- First you need to create a Userform.

- Right click on the toolbox and select "Additional Controls..."

- Check the box next to Calendar Control 9.0 and click OK. This will add a
calendar control to your toolbox.

- Place a Calendar control in the userform and size it how you want..

- Double click on the userform to bring up the code widow. In the top left
dropdown box select Calendar1. In the right dropdown select DblClick
- In the code window enter:
Private Sub Calendar1_DblClick()
ActiveSheet.Range("D5").Value = Calendar1.Value
End Sub

- You will need to create a command button on the sheet to open the userform.
In that sheet's code enter:
Private Sub CommandButton1_Click()
UserForm1.Show
End Sub

Hope that helps. PS if you find the MSCAL.HLP file on your hard drive it will
give you more info on customizing the calendar.



Jaemun wrote:
Anyone please help,

How to create a calendar using userform. I mean when user click on the
prefered date, it automatically display into a cell e.g. user click on 1,2,4
and 7 in the month of December, 2005 then click ok, the output display in
sheet1 cell (d5) as 1,2,4 and 7 Dec, 2005,

Thanks in advance.
Jaemun.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Calendar inhance

Hi Davidmal,

I've done this kind of method before, What I'm looking for right now is how
enable multi select on calendar e.g. when I click the calender on date 1,2,4
and 7 in the month of December, 2005 then click OK, I want the output will
display in sheet1 cell (d5) as "1,2,4 and 7 Dec, 2005".

Any hope, this could be done?

Jaemun.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 114
Default Calendar inhance

Try this,

Put below code to userform's codemodule having calendar control.

From the click event of calendar, dates were stored to the collection
and from the click event of the commandbutton1, all the dates were
written in activecell as per your format.


------------------------------------------------
Dim datecol As New Collection

Private Sub Calendar1_Click()
On Error Resume Next

'add dates to collection
datecol.Add Calendar1.Value, CStr(Calendar1.Value)

'Hide Month & Year Selector
Calendar1.ShowDateSelectors = False

End Sub

Private Sub CommandButton1_Click()
Dim msg

' if no dates selected then exit sub
If datecol.Count = 0 Then Exit Sub

For i = 1 To datecol.Count - 1
If i = 1 Then
msg = Day(datecol(i))
Else
msg = msg & ", " & Day(datecol(i))
End If
Next

If i = 1 Then
ActiveCell.Value = Format(datecol(i), "D MMM, YYYY")
Else
ActiveCell.Value = msg & " and " & Format(datecol(i), "D MMM,
YYYY")
End If

End Sub

----------------------------------------------------------


With this the user can't change the month or year after cliking on the
date first time.

Regards,
Shah Shailesh
http://members.lycos.co.uk/shahweb/
http://in.geocities.com/shahshaileshs/
(Excel Add-ins Page)

*** Sent via Developersdex http://www.developersdex.com ***
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Calendar inhance

Hi Shailesh Shah,

You've saved my day and I still need your help.

1. I want the selections also applicable for the date with different month
as well e.g. "28, 29 and 31 December 2005 and 2, 3 and 4 January, 2006"
(perhaps someone have any suggestions for the best format here).

2. As this is a matter of date, so, no matter which date user click first
and next, the cell value must "display the selected date" in proper
directions. E.g. 2,3,4 and not 3,2,4 etc. If you can make it out, I would
be greatfull for that.

After all, I really appreciate and valued your help.

Jaemun.

"Shailesh Shah" wrote in message
...
Try this,

Put below code to userform's codemodule having calendar control.

From the click event of calendar, dates were stored to the collection
and from the click event of the commandbutton1, all the dates were
written in activecell as per your format.


------------------------------------------------
Dim datecol As New Collection

Private Sub Calendar1_Click()
On Error Resume Next

'add dates to collection
datecol.Add Calendar1.Value, CStr(Calendar1.Value)

'Hide Month & Year Selector
Calendar1.ShowDateSelectors = False

End Sub

Private Sub CommandButton1_Click()
Dim msg

' if no dates selected then exit sub
If datecol.Count = 0 Then Exit Sub

For i = 1 To datecol.Count - 1
If i = 1 Then
msg = Day(datecol(i))
Else
msg = msg & ", " & Day(datecol(i))
End If
Next

If i = 1 Then
ActiveCell.Value = Format(datecol(i), "D MMM, YYYY")
Else
ActiveCell.Value = msg & " and " & Format(datecol(i), "D MMM,
YYYY")
End If

End Sub

----------------------------------------------------------


With this the user can't change the month or year after cliking on the
date first time.

Regards,
Shah Shailesh
http://members.lycos.co.uk/shahweb/
http://in.geocities.com/shahshaileshs/
(Excel Add-ins Page)

*** Sent via Developersdex http://www.developersdex.com ***





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 114
Default Calendar inhance


Hi Jaemun,


1. I want the selections also applicable for the date with different

month
as well e.g. "28, 29 and 31 December 2005 and 2, 3 and 4 January, 2006"
(perhaps someone have any suggestions for the best format here).


2. As this is a matter of date, so, no matter which date user click

first
and next, the cell value must "display the selected date" in proper
directions. E.g. 2,3,4 and not 3,2,4 etc. If you can make it out, I
would
be greatfull for that.



Try below codes:

1. Now selections is also applicable for the date with different
month\year.

e.g. "28, 29 and 31 December, 2005 and 2, 3 and 4 January, 2006"

2. Dates were sorted.























Regards,
Shah Shailesh
http://members.lycos.co.uk/shahweb/
http://in.geocities.com/shahshaileshs/
(Excel Add-ins Page)

*** Sent via Developersdex http://www.developersdex.com ***
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 114
Default Calendar inhance

Hi Jaemun,

Try this,
-----------------------------------------------------------
Dim DateCol As New Collection

Dim i As Long, CurMY As Long, NxtMY As Long, PrvMY As Long

Private Sub Calendar1_Click()

On Error Resume Next

'add dates to collection
DateCol.Add Format(Calendar1.Value, "#"), Format(Calendar1.Value, "#")

End Sub

Private Sub CommandButton1_Click()

Dim ResultDate, FullDateFmt, DayFmt

'if no dates selected then exit sub
If DateCol.Count = 0 Then Exit Sub

SortDate

FullDateFmt = Format(DateCol(1), "D MMM, YYYY")

For i = 1 To DateCol.Count - 1

FullDateFmt = Format(DateCol(i), "D MMM, YYYY")

DayFmt = Day(DateCol(i))

If i = 1 Then

If DateCol.Count 1 Then

If SameMonthYear Then

ResultDate = DayFmt

Else

ResultDate = FullDateFmt

End If

End If

Else

If SameMonthYear Then

ResultDate = IIf(SameMonthYear1, ResultDate & ", " & DayFmt, ResultDate
& " and " & DayFmt)

Else

ResultDate = ResultDate & " and " & FullDateFmt

End If

End If

Next

If i = 1 Then

ActiveCell.Value = FullDateFmt

Else

ActiveCell.Value = ResultDate & " and " & Format(DateCol(i), "D MMM,
YYYY")

End If

End Sub

Function SortDate()

Dim i As Long, j As Long, vtemp

For i = 1 To DateCol.Count - 1

For j = i + 1 To DateCol.Count

If DateCol(i) DateCol(j) Then

vtemp = DateCol(j)

DateCol.Remove j

DateCol.Add vtemp, vtemp, i

End If

Next j

Next i

End Function

Function SameMonthYear() As Boolean

GetMY

SameMonthYear = CurMY = NxtMY

End Function

Function SameMonthYear1() As Boolean

GetMY

SameMonthYear1 = CurMY = PrvMY

End Function

Sub GetMY()

CurMY = Month(DateCol(i)) & Year(DateCol(i))

NxtMY = Month(DateCol(i + 1)) & Year(DateCol(i + 1))

If i 1 Then PrvMY = Month(DateCol(i - 1)) & Year(DateCol(i - 1))

End Sub
--------------------------------------------------------
Regards,
Shah Shailesh
http://members.lycos.co.uk/shahweb/
http://in.geocities.com/shahshaileshs/
(Excel Add-ins Page)

*** Sent via Developersdex http://www.developersdex.com ***
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
Convert date from Gregorian Calendar to Hijri Calendar H.Alkhodary Excel Discussion (Misc queries) 1 February 21st 09 10:11 AM
find free sharware to include calendar pop or use calendar in cell ednc Excel Discussion (Misc queries) 2 April 14th 08 05:05 PM
how do i export excel calendar info to outlook calendar? Maggie Excel Discussion (Misc queries) 1 December 31st 07 10:27 PM
excel calendar - list of names displayed on calendar Brian'88 Excel Worksheet Functions 3 November 17th 06 10:31 PM
import calendar items from excel into outlook calendar jsewaiseh Excel Discussion (Misc queries) 0 September 2nd 05 03:53 PM


All times are GMT +1. The time now is 09:51 AM.

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"