Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hi I have never used a list box, with VBA before.. How do i do it when the list box can have several marked choices... i want my macro to add text is certain cells, depending on what i picked of the list in the list box. Thans -- Ctec ----------------------------------------------------------------------- Ctech's Profile: http://www.excelforum.com/member.php...fo&userid=2774 View this thread: http://www.excelforum.com/showthread.php?threadid=52472 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
If you have a form called myForm with a multiselection listbox called myListbox then With myForm.mylistBox 'Get the selected data in the ListBox For i = 0 To .ListCount - 1 'for each Group in the list If .Selected(i) Then 'do your thing here End If Next i End With regards Paul |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() For i = 0 To .ListCount - 1 on this part of the code I get 'run time error "424", - Objec required' Does this mean I missing some kind of "references" -- Ctec ----------------------------------------------------------------------- Ctech's Profile: http://www.excelforum.com/member.php...fo&userid=2774 View this thread: http://www.excelforum.com/showthread.php?threadid=52472 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Do you have a userform named myform and a listbox on that userform named
mylistbox? -- Regards, Tom Ogilvy "Ctech" wrote: For i = 0 To .ListCount - 1 on this part of the code I get 'run time error "424", - Object required' Does this mean I missing some kind of "references"? -- Ctech ------------------------------------------------------------------------ Ctech's Profile: http://www.excelforum.com/member.php...o&userid=27745 View this thread: http://www.excelforum.com/showthread...hreadid=524722 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() See code below: I have a list box, named cboSecondary which is in Sheet "combo". non of this is actuall yin a form. Sub Update_task_part() ' This macro adds the tasks picked in the List Box and adds them to th Tasks revenue part of the form ' Created by Christian Simonsen 21/03/06 Dim mRows As Long Dim i As Long Dim Msg As String ' hides/unhides the required rows depending on the number of task picked mRows = cboSecondary.Selected mRows = 10 - mRows Range("list_rev").Rows("" & mRows & ":10").EntireRow.Hidden = Tru ' Gets the task numbers for the rows ' With cboSecondary ' For i = 0 To .ListCount - 1 ' If .Selected(i) Then ' Msg = Msg & .List(i) & vbCrLf ' End If ' Next i ' End With ' If Len(Msg) = 0 Then ' Msg = "No items selected" ' End If ' MsgBox Msg End Su -- Ctec ----------------------------------------------------------------------- Ctech's Profile: http://www.excelforum.com/member.php...fo&userid=2774 View this thread: http://www.excelforum.com/showthread.php?threadid=52472 |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This worked for me. I assume cboSecondary is a LISTBOX (not a combobox) with
the multiselect property set to True Sub Update_task_part() ' This macro adds the tasks picked in the List Box and adds them to the ' Tasks revenue part of the form ' Created by Christian Simonsen 21/03/06 Dim mRows As Long Dim i As Long Dim Msg As String ' hides/unhides the required rows depending on the number of tasks ' picked mRows = 0 With cboSecondary For i = 0 To .ListCount - 1 If .Selected(i) Then mRows = mRows + 1 Next End With Range("list_rev").EntireRow.Hidden = False mRows = 10 - mRows + 1 Range("list_rev").Rows("" & _ mRows & ":10").EntireRow.Hidden = True ' Gets the task numbers for the rows With cboSecondary For i = 0 To .ListCount - 1 If .Selected(i) Then Msg = Msg & .List(i) & vbCrLf End If Next i End With If Len(Msg) = 0 Then Msg = "No items selected" Else MsgBox Msg End If End Sub -- Regards, Tom Ogilvy "Ctech" wrote: See code below: I have a list box, named cboSecondary which is in Sheet "combo". non of this is actuall yin a form. Sub Update_task_part() ' This macro adds the tasks picked in the List Box and adds them to the Tasks revenue part of the form ' Created by Christian Simonsen 21/03/06 Dim mRows As Long Dim i As Long Dim Msg As String ' hides/unhides the required rows depending on the number of tasks picked mRows = cboSecondary.Selected mRows = 10 - mRows Range("list_rev").Rows("" & mRows & ":10").EntireRow.Hidden = Tru ' Gets the task numbers for the rows ' With cboSecondary ' For i = 0 To .ListCount - 1 ' If .Selected(i) Then ' Msg = Msg & .List(i) & vbCrLf ' End If ' Next i ' End With ' If Len(Msg) = 0 Then ' Msg = "No items selected" ' End If ' MsgBox Msg End Sub -- Ctech ------------------------------------------------------------------------ Ctech's Profile: http://www.excelforum.com/member.php...o&userid=27745 View this thread: http://www.excelforum.com/showthread...hreadid=524722 |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Im still getting the same error "424, Object required".. -- Ctec ----------------------------------------------------------------------- Ctech's Profile: http://www.excelforum.com/member.php...fo&userid=2774 View this thread: http://www.excelforum.com/showthread.php?threadid=52472 |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Im still getting the same error "424, Object required".. -- Ctec ----------------------------------------------------------------------- Ctech's Profile: http://www.excelforum.com/member.php...fo&userid=2774 View this thread: http://www.excelforum.com/showthread.php?threadid=52472 |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Should I try to export the workbook to another computer and thest i there -- Ctec ----------------------------------------------------------------------- Ctech's Profile: http://www.excelforum.com/member.php...fo&userid=2774 View this thread: http://www.excelforum.com/showthread.php?threadid=52472 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Setting up a list where an item can only be picked once in Excel | Excel Worksheet Functions | |||
Posts not getting picked up | Excel Discussion (Misc queries) | |||
How validation dropdown list open when cell is picked?. | Excel Worksheet Functions | |||
How to disable a button picked from the Forms list. | Excel Programming | |||
Just a tip I have picked-up | Excel Programming |