+ Reply to Thread
Results 1 to 3 of 3

Copy Selected data from a List box

Hybrid View

danallamas Copy Selected data from a... 03-03-2015, 12:51 AM
:) Sixthsense :) Re: Copy Selected data from a... 03-03-2015, 01:32 AM
danallamas Re: Copy Selected data from a... 03-09-2015, 08:26 PM
  1. #1
    Registered User
    Join Date
    01-02-2014
    Location
    Philippines
    MS-Off Ver
    Excel 2010
    Posts
    95

    Exclamation Copy Selected data from a List box

    Guys I seriously need help on this.

    I have a listbox in the attached spreadsheet and I need to be able to copy selected data to Column E and List down all companies that match the selected data in column e to Column G. Companies and programs combined is in 'Company_Program Tab and listbox is based from 'Unique Programs Tab'

    The project aims to listdown companies that offer the programs selected.
    Attached Files Attached Files
    Last edited by danallamas; 03-09-2015 at 08:35 PM.

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Copy Selected data from a List box

    Instead of Form controls use ActiveX Listbox so that we can use vba code to do the job


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Registered User
    Join Date
    01-02-2014
    Location
    Philippines
    MS-Off Ver
    Excel 2010
    Posts
    95

    Re: Copy Selected data from a List box

    Thanks for the advice. I was able to get it to work

    Here's the code:

    Dim startNum As Integer
    Private Sub Btn_add_Click()
    Dim isExists
    listResult.Clear
    ListBox1.Height = 310
    listResult.Height = 310
    isExists = False
    For i = 0 To ListBox1.ListCount - 1
    If ListBox1.Selected(i) = True Then
    For j = 0 To listCompany.ListCount - 1
    If ListBox1.List(i, 0) = listCompany.List(j, 0) Then
    For k = 0 To listResult.ListCount - 1
    If listResult.List(k, 0) = listCompany.List(j, 1) Then
    isExists = True
    Exit For
    Else
    isExists = False
    End If
    Next k
    If Not isExists Then
    listResult.AddItem listCompany.List(j, 1)
    End If
    End If
    Next j
    End If
    Next i
    End Sub

    Private Sub btn_clear_Click()
    For i = 0 To ListBox1.ListCount - 1
    If ListBox1.Selected(i) Then
    ListBox1.Selected(i) = False
    End If
    Next i
    listResult.Clear
    End Sub

    Private Sub Btn_ClearRow_Click()
    startNum = 0
    Range("L7:L1129").ClearContents
    End Sub

    Private Sub CommandButton21_Click()
    Dim charNum As String
    charNum = "L"
    For k = 0 To listResult.ListCount - 1
    If listResult.Selected(k) = True Then
    Range(charNum & "" & k + 7).Value = listResult.List(k, 0)
    'MsgBox listResult.List(k, 0)
    startNum = startNum + 1
    End If
    Next k
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Copy row based on drop down list selected
    By joeycrak in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-10-2014, 05:27 PM
  2. Macro to copy entire row to the sheet selected from the list in the cell
    By ashu611 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-24-2012, 01:52 AM
  3. Code to Open A list of Path and copy a selected cell
    By roipatrick in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-21-2010, 02:40 PM
  4. copy data from selected cells , in selected row and paste it to ms word table ?
    By aaashaaa in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-06-2010, 03:25 PM
  5. Replies: 1
    Last Post: 06-05-2006, 03:55 PM

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