Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 385
Default listbox code

Hello all,
I found this code in the archives and it gets me going in the right
direction, but i am going to need further direction.
I have a userform with a multi select listbox i would like the selections to
be pasted to a worksheet ("GwrStmts").
So far the code only paste one column of the info and not all 3 that are in
the list box and i need it to paste the info in area "b20:d50" (this is my
selected print area)

Thank you in advance. Gracias!

Private Sub cmbSubmit_Click()
Dim i As Long
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
For i = 0 To Me.lstData.ListCount - 1
If Me.lstData.Selected(i) Then
ws.Range("Anchor").End(xlUp).Offset(1, 0) _
..Value = Me.lstData.List(i)
End If
Next i
End Sub

--
Though daily learning, I LOVE EXCEL!
Jennifer
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default listbox code

Hi Jennifer,

Private Sub cmbSubmit_Click()
Dim i As Long
dim j as long
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
For i = 0 To Me.lstData.ListCount - 1
If Me.lstData.Selected(i) Then
for j=0 to me.columns.count-1
ws.Range("Anchor").End(xlUp).Offset(1, j) _
..Value = Me.lstData.List(i,j)
next j
End If
Next i
End Sub

Regards,
Ivan

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default listbox code

sorry,

need to replace:
or j=0 to me.columns.count-1
with
or j=0 to me.istdata.columns.count-1

Regards,
Ivan

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default listbox code

or even

j=0 to me.lstdata.columns.count-1

--
Regards,
Tom Ogilvy


"Ivan Raiminius" wrote:

sorry,

need to replace:
or j=0 to me.columns.count-1
with
or j=0 to me.istdata.columns.count-1

Regards,
Ivan


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default listbox code

Private Sub cmbSubmit_Click()
Dim i As Long, j as Long
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
j = 0
For i = 0 To Me.lstData.ListCount - 1
If Me.lstData.Selected(i) Then
ws.Range("B20").Offset(j, 0) _
.Value = Me.lstData.List(i,0)
ws.Range("C20").Offset(j,0) _
.Value = Me.LstData.List(i,1)
ws.Range("D20").Offset(j,0) _
.Value = Me.LstData.List(i,2)
j = j + 1
End If
Next i
End Sub

--
Regards,
Tom Ogilvy


"Jennifer" wrote:

Hello all,
I found this code in the archives and it gets me going in the right
direction, but i am going to need further direction.
I have a userform with a multi select listbox i would like the selections to
be pasted to a worksheet ("GwrStmts").
So far the code only paste one column of the info and not all 3 that are in
the list box and i need it to paste the info in area "b20:d50" (this is my
selected print area)

Thank you in advance. Gracias!

Private Sub cmbSubmit_Click()
Dim i As Long
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
For i = 0 To Me.lstData.ListCount - 1
If Me.lstData.Selected(i) Then
ws.Range("Anchor").End(xlUp).Offset(1, 0) _
.Value = Me.lstData.List(i)
End If
Next i
End Sub

--
Though daily learning, I LOVE EXCEL!
Jennifer



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 385
Default listbox code

Thanks guys. It worked though i am really going to have to take a look at it
to understand. The i & j's have me confused. Thank you again! Jennifer
--
Though daily learning, I LOVE EXCEL!
Jennifer


"Tom Ogilvy" wrote:

Private Sub cmbSubmit_Click()
Dim i As Long, j as Long
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
j = 0
For i = 0 To Me.lstData.ListCount - 1
If Me.lstData.Selected(i) Then
ws.Range("B20").Offset(j, 0) _
.Value = Me.lstData.List(i,0)
ws.Range("C20").Offset(j,0) _
.Value = Me.LstData.List(i,1)
ws.Range("D20").Offset(j,0) _
.Value = Me.LstData.List(i,2)
j = j + 1
End If
Next i
End Sub

--
Regards,
Tom Ogilvy


"Jennifer" wrote:

Hello all,
I found this code in the archives and it gets me going in the right
direction, but i am going to need further direction.
I have a userform with a multi select listbox i would like the selections to
be pasted to a worksheet ("GwrStmts").
So far the code only paste one column of the info and not all 3 that are in
the list box and i need it to paste the info in area "b20:d50" (this is my
selected print area)

Thank you in advance. Gracias!

Private Sub cmbSubmit_Click()
Dim i As Long
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
For i = 0 To Me.lstData.ListCount - 1
If Me.lstData.Selected(i) Then
ws.Range("Anchor").End(xlUp).Offset(1, 0) _
.Value = Me.lstData.List(i)
End If
Next i
End Sub

--
Though daily learning, I LOVE EXCEL!
Jennifer

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default listbox code

Hi TOm! I have quite similar situation LIKE THAT OF Jennifer. I have a
worksheet which has the ff: data. Column A Column B
Teacher Subjects
myworksheet name is datamaint

The teacher can have many subjects but the subject can only have one teacher.

I've created a listbox control with teacher as its list what I want is that
when a user select a teacher all the subject that she's handling will appear
in another list (based on the data in datamaint worksheet) like these:
Teacher SUBJECTS
Ann ---Selected pROGRAMMING1
sYSTEM aNALYSIS AND dESIGN
dATABASE aNALYsis and design

The user should be able to select one subject. and push a SUBMIT button
which will save the selected teacher's name and subject into a worksheet
"TRANSACT".

I hope you can help me. Thanks in advanced!



"Tom Ogilvy" wrote:

Private Sub cmbSubmit_Click()
Dim i As Long, j as Long
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
j = 0
For i = 0 To Me.lstData.ListCount - 1
If Me.lstData.Selected(i) Then
ws.Range("B20").Offset(j, 0) _
.Value = Me.lstData.List(i,0)
ws.Range("C20").Offset(j,0) _
.Value = Me.LstData.List(i,1)
ws.Range("D20").Offset(j,0) _
.Value = Me.LstData.List(i,2)
j = j + 1
End If
Next i
End Sub

--
Regards,
Tom Ogilvy


"Jennifer" wrote:

Hello all,
I found this code in the archives and it gets me going in the right
direction, but i am going to need further direction.
I have a userform with a multi select listbox i would like the selections to
be pasted to a worksheet ("GwrStmts").
So far the code only paste one column of the info and not all 3 that are in
the list box and i need it to paste the info in area "b20:d50" (this is my
selected print area)

Thank you in advance. Gracias!

Private Sub cmbSubmit_Click()
Dim i As Long
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
For i = 0 To Me.lstData.ListCount - 1
If Me.lstData.Selected(i) Then
ws.Range("Anchor").End(xlUp).Offset(1, 0) _
.Value = Me.lstData.List(i)
End If
Next i
End Sub

--
Though daily learning, I LOVE EXCEL!
Jennifer

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Modification of listbox to listbox code Sam S via OfficeKB.com Excel Programming 0 July 28th 05 12:02 PM
Modification of listbox to listbox code R.VENKATARAMAN Excel Programming 0 July 28th 05 05:36 AM
Select an item in a listbox using code Fred Jacobowitz Excel Programming 2 August 23rd 04 03:27 AM
Listbox Propery code Mike Fogleman Excel Programming 3 January 1st 04 04:27 PM
ListBox List Code? Abdul[_4_] Excel Programming 1 October 10th 03 01:28 AM


All times are GMT +1. The time now is 01:44 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"