Writing multicolumn listbox values into a spreadsheet...

JST013

Board Regular
Joined
Mar 11, 2015
Messages
74
Ok so my end game here is to take whatever "row" is selected in the listbox and drop its values into a spreadsheet...


The values will always drop into the same locations so that is given.


Code:
   Private Sub btnBlah_Click()
        Dim blahvba()
        Dim ws As Worksheet
        Set ws = ThisWorkbook.Worksheets("Assembly")
        
     
    With Me.ListBox1
        For i = 0 To .ListCount - 1
            If .Selected(i) Then
                blahvba(i) = .Value
            End If
        Next i
            ws.Cells(1, 7) = blahvba(1)
            ws.Cells(1, 2) = blahvba(2)
            ws.Cells(1, 1) = blahvba(3)
            ws.Cells(1, 3) = blahvba(4)
            ws.Cells(1, 4) = blahvba(5)
            ws.Cells(1, 5) = blahvba(6)
    End With


End Sub


I'm not sure what I'm doing wrong...but I have a feeling trying to use an array isn't helping me...:rofl:
 
try

Code:
Dim X As Long
For X = 0 To Me.ListBox1.ColumnCount - 1
    Range("A1").Offset(, X).Value = Me.ListBox1.List(Me.ListBox1.ListIndex, X)
Next X
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top