Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / January 2008

Tip: Looking for answers? Try searching our database.

range as listbox column

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
BigPig - 23 Jan 2008 00:36 GMT
Hi All,

Can't figure out how to use a column of data from a listbox as a range.

Hope you can provide some advice.

I have an inventory database (wkbk), each item has a primary key, person,
office, sn etc... A userform is used to transfer equipment from a
person/office to another.
A listbox is used to list the items for transfer, the second column of the
lstbx holds the "primary key" value. By matching the primary key of the lstbx
to the primary key of the ws, I wish to update/append that particular row
with data found in 3 comboboxes (new person, office, etc).

This is what I have so far. The error I receive is "Error: 381: Could not
get the column property. Invalid property array index." (rng =
lst_map_trans_to.Column(2))

Dim i As Long
Dim ws As Worksheet
Set ws = Worksheets("Inventory")

For i = 0 To Me.lst_map_trans_to.ListCount - 1
Dim prkey As Variant
prkey = (lst_map_trans_to.List(i, 1) - 1)
Dim rng As Range
rng = lst_map_trans_to.Column(2)
For Each prkey In rng
Worksheets("mp").Range("j" & prkey) = cbx_map_office_to.Value
Worksheets("mp").Range("k" & prkey) = cbx_map_person_to.Value
Worksheets("mp").Range("l" & prkey) = cbx_map_loc_to.Value
Next
Next

Thanks for any and all advice.
Jim Cone - 23 Jan 2008 01:31 GMT
Add the Set statement at the beginning of the line...
Set rng = lst_map_trans_to.Columns(2).Cells
(note the addition of .Cells at the end and the s to Column)
Signature

Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)

"BigPig"
wrote in message
Hi All,

Can't figure out how to use a column of data from a listbox as a range.

Hope you can provide some advice.

I have an inventory database (wkbk), each item has a primary key, person,
office, sn etc... A userform is used to transfer equipment from a
person/office to another.
A listbox is used to list the items for transfer, the second column of the
lstbx holds the "primary key" value. By matching the primary key of the lstbx
to the primary key of the ws, I wish to update/append that particular row
with data found in 3 comboboxes (new person, office, etc).

This is what I have so far. The error I receive is "Error: 381: Could not
get the column property. Invalid property array index." (rng =
lst_map_trans_to.Column(2))

Dim i As Long
Dim ws As Worksheet
Set ws = Worksheets("Inventory")

For i = 0 To Me.lst_map_trans_to.ListCount - 1
Dim prkey As Variant
prkey = (lst_map_trans_to.List(i, 1) - 1)
Dim rng As Range
rng = lst_map_trans_to.Column(2)
For Each prkey In rng
Worksheets("mp").Range("j" & prkey) = cbx_map_office_to.Value
Worksheets("mp").Range("k" & prkey) = cbx_map_person_to.Value
Worksheets("mp").Range("l" & prkey) = cbx_map_loc_to.Value
Next
Next

Thanks for any and all advice.

BigPig - 25 Jan 2008 15:01 GMT
Hi Jim,

Thank you! You're right that's all it needed.

> Add the Set statement at the beginning of the line...
> Set rng = lst_map_trans_to.Columns(2).Cells
> (note the addition of .Cells at the end and the s to Column)
Jim Cone - 25 Jan 2008 15:22 GMT
You are welcome, the feedback is appreciated.
Signature

Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)

"BigPig"
wrote in message
Hi Jim,
Thank you! You're right that's all it needed.

"Jim Cone" wrote:

> Add the Set statement at the beginning of the line...
> Set rng = lst_map_trans_to.Columns(2).Cells
> (note the addition of .Cells at the end and the s to Column)
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.