LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Insert dates from a userform

Bob,

I was just browsing through some other issues I'd posted and saw your
solution. I had proposed the following in a separate post, but I didnt
dissect or try your code. How does this compare to yours? Which is
preferable/more efficient if any?

Thanks,

______________________________

leonidas,

It's a little more work than your approach, but it works, and you should be
able to adapt this to your needs...

Private Sub Dates()
Dim NumDays, DayOfWeek, CurrentRow, i As Integer
Dim StartD, EndD As Date

StartD = CDate(Textbox3.text)
EndD = CDate(Textbox4.text)

CurrentRow = 10

'Numdays is the actual number of days
NumDays = DateDiff("d", StartD, EndD)

For i = 0 To NumDays

'Use function to identify ordinal day of week with Monday = 1
DayOfWeek = Weekday(DateAdd("d", i, StartD), vbMonday)

'if day of week is not Sat(6) or Sun(7) then write the date and increment
row

If DayOfWeek < 6 And DayOfWeek < 7 Then
Range("B" & CStr(CurrentRow)).Value = DateAdd("d", i, StartD)
CurrentRow = CurrentRow + 1
End If

'check next date in range
Next i

End Sub




 
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
UserForm to insert new data dschanak Excel Discussion (Misc queries) 1 August 1st 07 09:40 PM
Insert dates from a userform leonidas[_54_] Excel Programming 1 August 2nd 06 09:10 AM
Insert a date from a userform Bob Phillips Excel Programming 0 July 27th 06 01:20 PM
Insert a date from a userform ChasAA Excel Programming 0 July 27th 06 01:03 PM
Insert row if box on userform is checked Steph[_3_] Excel Programming 2 July 30th 04 04:28 PM


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