Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / March 2006

Tip: Looking for answers? Try searching our database.

For each picked entitiy in a list box...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ctech - 21 Mar 2006 11:02 GMT
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
paul.robinson@it-tallaght.ie - 21 Mar 2006 12:31 GMT
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
Ctech - 21 Mar 2006 13:18 GMT
> 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
Tom Ogilvy - 21 Mar 2006 13:51 GMT
Do you have a userform named myform and a listbox on that userform named
mylistbox?

Signature

Regards,
Tom Ogilvy

> > 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 - 21 Mar 2006 14:45 GMT
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
[quoted text clipped - 27 lines]
>
> End Su

--
Ctec
Tom Ogilvy - 21 Mar 2006 15:33 GMT
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

Signature

Regards,
Tom Ogilvy

> See code below:
>
[quoted text clipped - 32 lines]
> >
> > End Sub
Ctech - 21 Mar 2006 15:41 GMT
Im still getting the same error "424, Object required"..

--
Ctec
Ctech - 21 Mar 2006 15:42 GMT
Im still getting the same error "424, Object required"..

--
Ctec
Ctech - 21 Mar 2006 18:28 GMT
Should I try to export the workbook to another computer and thest i
there

--
Ctec
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.