View Single Post
  #4   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
Dim iLastCol As Long
Dim cell As Range

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

For Each cell In Range("B10").Resize(cDays)
If Weekday(cell.Value) = 6 Then
iLastCol = Cells(cell.Row, Columns.Count).End(xlToLeft).Column
With cell.Resize(, iLastCol - cell.Column +
1).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThick
End With
End If
Next cell


--
HTH

Bob Phillips

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

"leonidas" wrote in
message ...

Hi Bob,

Thanks for your help!
I do have another question though. Is it also possible to insert a
border on the bottom of every row with a friday. The border should
start from the cell with the date in it (is column B) and the end is
variable. The end is the last column with a value in it on the same
row.
Hope you can help me with this one! Thanks in advance!


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

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