Results 1 to 3 of 3
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Fill column with days based var (2000)

    have a listbox in userform filled with month(in italian Dicembre, Gennaio....) and a listbox with Year (2008 to 2012)
    How to fill column I (start from I2) with all days of month selected from listbox based Year?
    Note:
    Autocaculate Febrary days based year selected.

  2. #2
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Fill column with days based var (2000)

    Presuming taht the months are in a listbox named Listbox1 and the years are Listbox2, you can have a commandbutton1 created that when pressed will fill in the days with code like:

    <pre>Option Explicit
    Private Sub CommandButton1_Click()
    Dim iMonth As Integer
    Dim dDate As Date
    Dim rCell As Range
    Dim i As Integer

    Set rCell = Range("I2")
    Range(rCell, rCell.Offset(30, 0)).ClearContents
    iMonth = ListBox1.ListIndex + 1
    dDate = DateSerial(ListBox2.Value, iMonth, 1)
    i = 0
    Do While iMonth = Month(dDate)
    rCell.Offset(i, 0) = dDate
    i = i + 1
    dDate = dDate + 1
    Loop
    End Sub</pre>


    Steve

  3. #3
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Fill column with days based var (2000)

    Perfect! Tks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •