Getting form list box results into columns on spreadsheet help.

bphall

New Member
Joined
Mar 8, 2011
Messages
11
Ok, so I was able to get my txt boxes to show up on my excel sheet, but the listboxes won't show up, I do have the option to select multiple selections with each list box.

Code is below...I appreciate the help once again.

Code:
Private Sub cmdSubmit_Click()
    
    Dim irow As Long
    Dim ws As Worksheet
    
    
    Set ws = Sheets("Results")
    
    
    irow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
    
    Application.ScreenUpdating = False
    
    With ws
    .Range("A" & irow) = TxtBxCompany.Value
    .Range("B" & irow) = TxtBxWellname.Value
    .Range("C" & irow) = TxtBxRun.Value
    .Range("D" & irow) = TxtBxCounty.Value
    .Range("E" & irow) = cbxDistrict.Value
    .Range("F" & irow) = cbxLocation.Value
    .Range("G" & irow) = TxtBxCustomer.Value
    .Range("H" & irow) = TxtBxPhone.Value
    .Range("I" & irow) = lstbxLoggingServiceType.Value
    .Range("J" & irow) = lstbxAcoustic.Value
    
    
    End With
   
    TxtBxCompany.Value = ""
    TxtBxWellname.Value = ""
    
    Application.ScreenUpdating = True
    Unload Me

    
End Sub
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
If you have the MultiSelect property enabled then you will need to loop through the ListBox and build up a text string for output.

For example, using your Accoustic Lixt box:

Code:
   [COLOR=darkblue]Dim[/COLOR] txt [COLOR=darkblue]As[/COLOR] [COLOR=darkblue]String[/COLOR]
   [COLOR=darkblue]Dim[/COLOR] i [COLOR=darkblue]As[/COLOR] [COLOR=darkblue]Integer[/COLOR]
 
   [COLOR=darkblue]For[/COLOR] i = 0 [COLOR=darkblue]To[/COLOR] lstbxAcoustic.ListCount - 1
      [COLOR=darkblue]If[/COLOR] lstbxAcoustic.Selected(i) = [COLOR=darkblue]True[/COLOR] [COLOR=darkblue]Then[/COLOR]
         txt = txt & lstbxAcoustic.List(i) & " "
      [COLOR=darkblue]End[/COLOR] [COLOR=darkblue]If[/COLOR]
   [COLOR=darkblue]Next[/COLOR] i
 
   ws.Range("J" & irow).Value = txt
 
Upvote 0

Forum statistics

Threads
1,224,552
Messages
6,179,488
Members
452,917
Latest member
MrsMSalt

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