+ Reply to Thread
Results 1 to 3 of 3

Combo Box fill

  1. #1
    Hal
    Guest

    Combo Box fill

    Hello all,

    The UserForm_Initialize sub populates the first combo box. The
    cbSPCsheets_Change sub fills the second combo box.

    I would like to populate this combo box with all but the sheet seleted in
    the first combo box. Is this accomplished by use of the items index number?
    If so, would it be better to delete that item in the second combo box or can
    it be passed by at fill time?

    I guess another option would be to add a check to determine if the same item
    is selected in both combo boxes and prompt to make another selection in box
    two.

    You thoughts and solutions. . .

    Hal



    Option Explicit

    Private Sub UserForm_Initialize()
    ' Fill cbSPCsheets
    Dim cSheets As Integer
    Dim i As Integer
    cSheets = Sheets.Count
    cbSPCsheets.Clear
    For i = 1 To cSheets
    cbSPCsheets.AddItem Sheets(i).Name
    Next
    End Sub

    Private Sub cbSPCsheets_Change()
    ' Fill cbDIRsheets
    Dim cSheets As Integer
    Dim i As Integer
    lblDIRlisting.Enabled = True
    cbDIRsheets.Enabled = True
    cSheets = Sheets.Count
    cbDIRsheets.Clear
    For i = 1 To cSheets
    cbDIRsheets.AddItem Sheets(i).Name
    Next
    End Sub

    Private Sub cbDIRsheets_Change()
    cmbCompare.Enabled = True
    End Sub

    Private Sub cmbCancel_Click()
    Unload frmCompareSPCtoDIR
    End Sub

  2. #2
    Tom Ogilvy
    Guest

    Re: Combo Box fill

    For i = 1 To cSheets
    if Sheets(i).Name <> cbSPCsheets.Value then
    cbDIRsheets.AddItem Sheets(i).Name
    end if
    Next

    If the sheet isn't in the choices, then you don't need to worry about a
    conflict.
    --
    Regards,
    Tom Ogilvy


    "Hal" <fsuTonkNoSpam@netscape.net> wrote in message
    news:8316111A-DB03-4428-B3D5-AE60B44C89CC@microsoft.com...
    > Hello all,
    >
    > The UserForm_Initialize sub populates the first combo box. The
    > cbSPCsheets_Change sub fills the second combo box.
    >
    > I would like to populate this combo box with all but the sheet seleted in
    > the first combo box. Is this accomplished by use of the items index

    number?
    > If so, would it be better to delete that item in the second combo box or

    can
    > it be passed by at fill time?
    >
    > I guess another option would be to add a check to determine if the same

    item
    > is selected in both combo boxes and prompt to make another selection in

    box
    > two.
    >
    > You thoughts and solutions. . .
    >
    > Hal
    >
    >
    >
    > Option Explicit
    >
    > Private Sub UserForm_Initialize()
    > ' Fill cbSPCsheets
    > Dim cSheets As Integer
    > Dim i As Integer
    > cSheets = Sheets.Count
    > cbSPCsheets.Clear
    > For i = 1 To cSheets
    > cbSPCsheets.AddItem Sheets(i).Name
    > Next
    > End Sub
    >
    > Private Sub cbSPCsheets_Change()
    > ' Fill cbDIRsheets
    > Dim cSheets As Integer
    > Dim i As Integer
    > lblDIRlisting.Enabled = True
    > cbDIRsheets.Enabled = True
    > cSheets = Sheets.Count
    > cbDIRsheets.Clear
    > For i = 1 To cSheets
    > cbDIRsheets.AddItem Sheets(i).Name
    > Next
    > End Sub
    >
    > Private Sub cbDIRsheets_Change()
    > cmbCompare.Enabled = True
    > End Sub
    >
    > Private Sub cmbCancel_Click()
    > Unload frmCompareSPCtoDIR
    > End Sub




  3. #3
    Hal
    Guest

    Re: Combo Box fill

    Thanks once again Tom,

    Your expertise is greatly appreciated!

    Hal

    "Tom Ogilvy" wrote:

    > For i = 1 To cSheets
    > if Sheets(i).Name <> cbSPCsheets.Value then
    > cbDIRsheets.AddItem Sheets(i).Name
    > end if
    > Next
    >
    > If the sheet isn't in the choices, then you don't need to worry about a
    > conflict.
    > --
    > Regards,
    > Tom Ogilvy
    >
    >
    > "Hal" <fsuTonkNoSpam@netscape.net> wrote in message
    > news:8316111A-DB03-4428-B3D5-AE60B44C89CC@microsoft.com...
    > > Hello all,
    > >
    > > The UserForm_Initialize sub populates the first combo box. The
    > > cbSPCsheets_Change sub fills the second combo box.
    > >
    > > I would like to populate this combo box with all but the sheet seleted in
    > > the first combo box. Is this accomplished by use of the items index

    > number?
    > > If so, would it be better to delete that item in the second combo box or

    > can
    > > it be passed by at fill time?
    > >
    > > I guess another option would be to add a check to determine if the same

    > item
    > > is selected in both combo boxes and prompt to make another selection in

    > box
    > > two.
    > >
    > > You thoughts and solutions. . .
    > >
    > > Hal
    > >
    > >
    > >
    > > Option Explicit
    > >
    > > Private Sub UserForm_Initialize()
    > > ' Fill cbSPCsheets
    > > Dim cSheets As Integer
    > > Dim i As Integer
    > > cSheets = Sheets.Count
    > > cbSPCsheets.Clear
    > > For i = 1 To cSheets
    > > cbSPCsheets.AddItem Sheets(i).Name
    > > Next
    > > End Sub
    > >
    > > Private Sub cbSPCsheets_Change()
    > > ' Fill cbDIRsheets
    > > Dim cSheets As Integer
    > > Dim i As Integer
    > > lblDIRlisting.Enabled = True
    > > cbDIRsheets.Enabled = True
    > > cSheets = Sheets.Count
    > > cbDIRsheets.Clear
    > > For i = 1 To cSheets
    > > cbDIRsheets.AddItem Sheets(i).Name
    > > Next
    > > End Sub
    > >
    > > Private Sub cbDIRsheets_Change()
    > > cmbCompare.Enabled = True
    > > End Sub
    > >
    > > Private Sub cmbCancel_Click()
    > > Unload frmCompareSPCtoDIR
    > > End Sub

    >
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1