Dear all,

Thanks for your help!


2012/5/17 dguillett1 <dguille...@gmail.com>

>   Sub dates()
> days = Day(DateSerial(Year(Date), myMonth + 1, 1) - 1)
> MsgBox days
> Set myrange = Range("b1: b”& days)
> With myrange.Cells(1)
> .Value = DateSerial(Year(Date), Month(Date), 1)
> .AutoFill Destination:=myrange, Type:=xlFillDays
> End With
> End Sub
>
> Don Guillett
> Microsoft MVP Excel
> SalesAid Software
> dguille...@gmail.com
>
>  *From:* Darwin Chan <darwin.chankaw...@gmail.com>
> *Sent:* Thursday, May 17, 2012 1:15 AM
> *To:* excel-macros@googlegroups.com
> *Subject:* $$Excel-Macros$$ Ask for improvement for procedure for date
> filling
>
>
> Dear all,
>
> I have written a simple procedure to fill cells with dates, it depends on
> the current month and decide the range of the cells.
>
> Can anyone suggest any room for improvement for my code?
>
>  Sub monthfill()
> Dim myrange As Range
> Dim mth As Integer
> Cells.Clear
>
>
> mth = month(Date)
>
>
> Select Case mth
> Case 1, 3, 5, 7, 8, 10, 12
> Set myrange = Range("B1: B31")
> With myrange.Cells(1)
>         .Value = DateSerial(Year(Date), month(Date), 1)
>         .AutoFill Destination:=myrange, Type:=xlFillDays
>     End With
>
>
> Case 4, 6, 9, 11
> Set myrange = Range("B1: B30")
> With myrange.Cells(1)
>         .Value = DateSerial(Year(Date), month(Date), 1)
>         .AutoFill Destination:=myrange, Type:=xlFillDays
>   End With
>
> Case 2
> Set myrange = Range("B1: B28")
> With myrange.Cells(1)
>         .Value = DateSerial(Year(Date), month(Date), 1)
>         .AutoFill Destination:=myrange, Type:=xlFillDays
>   End With
>
> End Select
> Set myrange = Nothing
> End Sub
>
>
> Darwin
>
> --
> FORUM RULES (986+ members already BANNED for violation)
>
> 1) Use concise, accurate thread titles. Poor thread titles, like Please
> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice
> will not get quick attention or may not be answered.
>
> 2) Don't post a question in the thread of another member.
>
> 3) Don't post questions regarding breaking or bypassing any security
> measure.
>
> 4) Acknowledge the responses you receive, good or bad.
>
> 5) Cross-promotion of, or links to, forums competitive to this forum in
> signatures are prohibited.
>
> NOTE : Don't ever post personal or confidential data in a workbook. Forum
> owners and members are not responsible for any loss.
>
>
> ------------------------------------------------------------------------------------------------------
> To post to this group, send email to excel-macros@googlegroups.com
>
> --
> FORUM RULES (986+ members already BANNED for violation)
>
> 1) Use concise, accurate thread titles. Poor thread titles, like Please
> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice
> will not get quick attention or may not be answered.
>
> 2) Don't post a question in the thread of another member.
>
> 3) Don't post questions regarding breaking or bypassing any security
> measure.
>
> 4) Acknowledge the responses you receive, good or bad.
>
> 5) Cross-promotion of, or links to, forums competitive to this forum in
> signatures are prohibited.
>
> NOTE : Don't ever post personal or confidential data in a workbook. Forum
> owners and members are not responsible for any loss.
>
>
> ------------------------------------------------------------------------------------------------------
> To post to this group, send email to excel-macros@googlegroups.com
>



-- 
Best Regards,
Darwin Chan
darwin.chankaw...@gmail.com
kw42c...@yahoo.com.hk

-- 
FORUM RULES (986+ members already BANNED for violation)

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.

2) Don't post a question in the thread of another member.

3) Don't post questions regarding breaking or bypassing any security measure.

4) Acknowledge the responses you receive, good or bad.

5)  Cross-promotion of, or links to, forums competitive to this forum in 
signatures are prohibited. 

NOTE  : Don't ever post personal or confidential data in a workbook. Forum 
owners and members are not responsible for any loss.

------------------------------------------------------------------------------------------------------
To post to this group, send email to excel-macros@googlegroups.com

Reply via email to