Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Modification of listbox to listbox code | Excel Programming | |||
Modification of listbox to listbox code | Excel Programming | |||
Select an item in a listbox using code | Excel Programming | |||
Listbox Propery code | Excel Programming | |||
ListBox List Code? | Excel Programming |