View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default Insert dates from a userform

Dim cDays As Long
Dim sFormula As String

With Range("B10")
.NumberFormat = "dd/mm/yyyy"
sFormula = "=SUMPRODUCT(--(WEEKDAY(ROW(" & _
CLng(CDate(TextBox3.Text)) & ":" &
CLng(CDate(TextBox4.Text)) & _
"),2)<6))"
.Formula = sFormula
cDays = .Value
.Value = CDate(TextBox3.Text)
.AutoFill .Resize(cDays + 1), Type:=xlFillWeekdays
End With


Not sure that you still want the + 1

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"leonidas" wrote in
message ...

Hi,

I have a userform with textbox3 and textbox4. The user can insert a
startdate in textbox3 and insert an enddate in textbox4. The code below
fills cells B10 and below with the dates between the startdate and
enddate and the weekends are excluded. The only problem is that by
excluding the weekends the enddate automatically changes to a later
date.
What should I change to get the enddate as last date in column B and
still exclude the weekends? Thanks in advance!


Code:
--------------------
Range("B10").Select
With Selection
.Value = CDate(TextBox3.Text)
.NumberFormat = "dd/mm/yyyy"
.AutoFill .Resize(CDate(TextBox4.Text) - CDate(TextBox3.Text) _
+ 1), Type:=xlFillWeekdays
End With
--------------------


--
leonidas
------------------------------------------------------------------------
leonidas's Profile:

http://www.excelforum.com/member.php...o&userid=35375
View this thread: http://www.excelforum.com/showthread...hreadid=566534