How to print all columns from a multi column listbox?

S

Simon Lloyd

Hi all, i have a 4 column listbox on a userform populated like this


VBA Code:
--------------------


With UserForm1.ListBox
.AddItem rng.Addres
.List(.ListCount - 1, 1) = rng.Offset(0, -29).Valu
.List(.ListCount - 1, 2) = rng.Offset(0, -25).Valu
.List(.ListCount - 1, 3) = rng.Offset(0, -24).Valu
ic = ic +
End With
--------------------


i now want to print all 4 columns as seen in the listbox, coul
someone explain how?


--
Simon Lloyd

Regards
Simon Lloyd
'Excel Chat' (http://www.thecodecage.com/forumz/chat.php)
 
J

Jim Cone

Add a worksheet, write the list to the worksheet, print the worksheet, delete the worksheet.
--
Jim Cone
Portland, Oregon USA



"Simon Lloyd" <[email protected]>
wrote in message
Hi all, i have a 4 column listbox on a userform populated like this:
VBA Code:
--------------------
With UserForm1.ListBox1
.AddItem rng.Address
.List(.ListCount - 1, 1) = rng.Offset(0, -29).Value
.List(.ListCount - 1, 2) = rng.Offset(0, -25).Value
.List(.ListCount - 1, 3) = rng.Offset(0, -24).Value
ic = ic + 1
End With
 
S

Simon Lloyd

Jim, thanks for the reply, i did try as you suggested, however i
either only wrote the first value from the first column or wrote th
value of the selected item but not the corresponding data in the sam
row in the other 3 columns

Could you give an example please on writing the data eg. column 1 t
column A, column 2 to coulmn B...et

Add a worksheet, write the list to the worksheet, print the worksheet
delete the worksheet
-
Jim Con
Portland, Oregon US



"Simon Lloyd" <[email protected]
wrote in message
Hi all, i have a 4 column listbox on a userform populated like this
VBA Code
-------------------
With UserForm1.ListBox
.AddItem rng.Addres
.List(.ListCount - 1, 1) = rng.Offset(0, -29).Valu
.List(.ListCount - 1, 2) = rng.Offset(0, -25).Valu
.List(.ListCount - 1, 3) = rng.Offset(0, -24).Valu
ic = ic +
End Wit
-------------------
i now want to print all 4 columns as seen in the listbox, coul
someone explain how
-
Simon Lloy

Regards
Simon Lloyd


--
Simon Lloyd

Regards
Simon Lloyd
'Excel Chat' (http://www.thecodecage.com/forumz/chat.php)
 
J

Jim Cone

Simon,

In the form module...
Worksheets("Sludge").Range("B2").Resize(ListBox1.ListCount - 1, ListBox1.ColumnCount).Value = ListBox1.List
--
Jim Cone
Portland, Oregon USA
(Special Sort... http://www.contextures.com/excel-sort-addin.html
30+ additional ways to sort)



"Simon Lloyd" <[email protected]>
wrote in message Jim, thanks for the reply, i did try as you suggested, however it
either only wrote the first value from the first column or wrote the
value of the selected item but not the corresponding data in the same
row in the other 3 columns.

Could you give an example please on writing the data eg. column 1 to
column A, column 2 to coulmn B...etc



Add a worksheet, write the list to the worksheet, print the worksheet,
delete the worksheet.
--
Jim Cone
Portland, Oregon USA



"Simon Lloyd" <[email protected]>
wrote in message Hi all, i have a 4 column listbox on a userform populated like this:
VBA Code:
--------------------
With UserForm1.ListBox1
AddItem rng.Address
List(.ListCount - 1, 1) = rng.Offset(0, -29).Value
List(.ListCount - 1, 2) = rng.Offset(0, -25).Value
List(.ListCount - 1, 3) = rng.Offset(0, -24).Value
ic = ic + 1
End With
--------------------
i now want to print all 4 columns as seen in the listbox, could
someone explain how?
--
Simon Lloyd

Regards,
Simon Lloyd


--
Simon Lloyd

Regards,
Simon Lloyd
'Excel Chat' (http://www.thecodecage.com/forumz/chat.php)
 
S

Simon Lloyd

Thanks Jim worked a treat, i had previously tried something similar
Sheets("PrintBox").Range("A1").Resize(ic, 4) = UserForm1.ListBox

Where ic was an iteration count as items were added top the list but i
didn't perform, thanks for clearing that up

Simon

In the form module..
Worksheets("Sludge").Range("B2").Resize(ListBox1.ListCount - 1
ListBox1.ColumnCount).Value = ListBox1.Lis
-
Jim Con
Portland, Oregon US
(Special Sort... 'Excel Sort Addin
(http://www.contextures.com/excel-sort-addin.html
30+ additional ways to sort



"Simon Lloyd" <[email protected]
wrote in message Jim, thanks for the reply, i did try as you suggested, however i
either only wrote the first value from the first column or wrote th
value of the selected item but not the corresponding data in the sam
row in the other 3 columns

Could you give an example please on writing the data eg. column 1 t
column A, column 2 to coulmn B...et




Jim Cone;686899 Wrote

Add a worksheet, write the list to the worksheet, print the worksheet
delete the worksheet
-
Jim Con
Portland, Oregon US



"Simon Lloyd" <[email protected]
wrote in message Hi all, i have a 4 column listbox on a userform populated like this
VBA Code
-------------------
With UserForm1.ListBox
AddItem rng.Addres
List(.ListCount - 1, 1) = rng.Offset(0, -29).Valu
List(.ListCount - 1, 2) = rng.Offset(0, -25).Valu
List(.ListCount - 1, 3) = rng.Offset(0, -24).Valu
ic = ic +
End Wit
-------------------
i now want to print all 4 columns as seen in the listbox, coul
someone explain how
-
Simon Lloy

Regards
Simon Lloy


-
Simon Lloy

Regards
Simon Lloy
'Excel Chat' (http://www.thecodecage.com/forumz/chat.php
-----------------------------------------------------------------------
Simon Lloyd's Profile:
View this thread: 'How to print all columns from a multi colum
listbox? - The Code Cage Forums
(http://www.thecodecage.com/forumz/showthread.php?t=191929

'Microsoft Office Help - Microsoft Office Discussion - Excel VB
Programming - Access Programming' (http://www.thecodecage.com/forumz)


--
Simon Lloyd

Regards
Simon Lloyd
'Excel Chat' (http://www.thecodecage.com/forumz/chat.php)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top