简体   繁体   中英

power point drop box

I have created the following dropbox in a power point presentation, I would like to be able to extend the number of dates available to the user to around 10 years. This clearly is a lot of dates and having to hard code around 3600 days is clearly not efficient. Is there anyway of being able to reference a named range, as you would in excel? Could you reference a named range in some kind of a supporting spreadsheet?

 Private Sub ComboBox1_GotFocus()
 If ComboBox1.ListCount = 0 Then
 AddDropDownItems
 End If
 End Sub

 Sub AddDropDownItems()
 ComboBox1.AddItem "10/02/2007"
 ComboBox1.AddItem "11/02/2007"
 ComboBox1.AddItem "12/02/2007"
 ....
 ComboBox1.ListRows = 3600
 End Sub

Thanks

You will want to use a loop so you dont have all of those individual lines:

Dim nIndex As Integer
For nIndex = 0 To 3600
  ComboBox1.AddItem DateAdd("m", nIndex, CVDate("10/02/2007"))
Next

You can change the "m" (month) to "d" (days) if you want to increment by days.

DateAdd Function

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM