Results 1 to 7 of 7

copying multiple listbox values to new sheet

Threaded View

  1. #1
    Forum Contributor
    Join Date
    08-04-2010
    Location
    singapore
    MS-Off Ver
    Excel 2007
    Posts
    143

    copying multiple listbox values to new sheet

    Hi,

    i am currently having troubles writing code to copy multiple selected listbox values to a new sheet.what i am hoping to do is to let user select some items in listbox and show the selected name,risk value and cost on sheet 2.the risk value is calculated with a formula(age + length), cost (length+diameter). The code below is what i managed to find at the moment, however it will show all the values of name,risk value,cost,age,length,diameter. if i delete the values of age, length and diameter, the risk value and cost will turn to "0". So i am wondering if there is any code that can copy the info in listbox straight to sheet 2 instead of referring to sheet1.
    any help will be greatly appreciated

    Private Sub Commandbutton1_click()
    dim a As Long
    dim i As Long
    a =1
    For i = 0 To ListBox1.ListCount - 1
    If Listbox1.selected(i) = True Then
    worksheets("sheet1").Cells(i+1,1).EntireRow.Copy
    Worksheets("sheet2").Cells(a,1).pastespecial
    a = a+1
    End If
    Next i
    End sub


    sheet 1
    name risk value cost age length diameter
    a
    b
    c
    d
    e

    listbox
    name risk value cost
    a
    b
    c
    d
    e
    Last edited by dan2010; 08-16-2010 at 05:25 AM.

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