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

I have the following code:

Private Sub ListBox1_Change()
Dim i As Integer
Dim cnt As Integer
Dim num As Integer
Dim j As Integer

num = ListBox1.ListCount
ReDim a(num, 7)
cnt = 0
For i = 0 To num - 1
If ListBox1.Selected(i) = True Then
cnt = cnt + 1
For j = 0 To 6
a(cnt, j) = ListBox1.List()
MsgBox ("a(" & cnt & "," & j & ")= " & a(cnt, j))
Next

End If
Next


End Sub

I am trying to get the data from the selected items on a listbox in a
userform. The list box has 7 columns. When i select an item in the listbox,
I get a 'type mismatch' error. How do I collect the data from a selected
rows in a listbox?
Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Listbox data

The data in array a(1,0) is empty. I think you need the following change

from
a(cnt, j) = ListBox1.List()
to
a(cnt, j) = ListBox1.List(j)

"ranswrt" wrote:

I have the following code:

Private Sub ListBox1_Change()
Dim i As Integer
Dim cnt As Integer
Dim num As Integer
Dim j As Integer

num = ListBox1.ListCount
ReDim a(num, 7)
cnt = 0
For i = 0 To num - 1
If ListBox1.Selected(i) = True Then
cnt = cnt + 1
For j = 0 To 6
a(cnt, j) = ListBox1.List()
MsgBox ("a(" & cnt & "," & j & ")= " & a(cnt, j))
Next

End If
Next


End Sub

I am trying to get the data from the selected items on a listbox in a
userform. The list box has 7 columns. When i select an item in the listbox,
I get a 'type mismatch' error. How do I collect the data from a selected
rows in a listbox?
Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 191
Default Listbox data

I changed it to 'a(cnt, j) = ListBox1.List(j)' , but the data in 'a' isn't
what I wanted. I am trying to get 'a' to get the data on a row that has been
selected on the listbox. There is 7 columns and i need data from each column
in 'a'. What am I doing wrong?
Thanks


"Joel" wrote:

The data in array a(1,0) is empty. I think you need the following change

from
a(cnt, j) = ListBox1.List()
to
a(cnt, j) = ListBox1.List(j)

"ranswrt" wrote:

I have the following code:

Private Sub ListBox1_Change()
Dim i As Integer
Dim cnt As Integer
Dim num As Integer
Dim j As Integer

num = ListBox1.ListCount
ReDim a(num, 7)
cnt = 0
For i = 0 To num - 1
If ListBox1.Selected(i) = True Then
cnt = cnt + 1
For j = 0 To 6
a(cnt, j) = ListBox1.List()
MsgBox ("a(" & cnt & "," & j & ")= " & a(cnt, j))
Next

End If
Next


End Sub

I am trying to get the data from the selected items on a listbox in a
userform. The list box has 7 columns. When i select an item in the listbox,
I get a 'type mismatch' error. How do I collect the data from a selected
rows in a listbox?
Thanks

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Listbox data

I wasn't sure what value you wre looking for try this

a(cnt, j) = ListBox1.value

"ranswrt" wrote:

I changed it to 'a(cnt, j) = ListBox1.List(j)' , but the data in 'a' isn't
what I wanted. I am trying to get 'a' to get the data on a row that has been
selected on the listbox. There is 7 columns and i need data from each column
in 'a'. What am I doing wrong?
Thanks


"Joel" wrote:

The data in array a(1,0) is empty. I think you need the following change

from
a(cnt, j) = ListBox1.List()
to
a(cnt, j) = ListBox1.List(j)

"ranswrt" wrote:

I have the following code:

Private Sub ListBox1_Change()
Dim i As Integer
Dim cnt As Integer
Dim num As Integer
Dim j As Integer

num = ListBox1.ListCount
ReDim a(num, 7)
cnt = 0
For i = 0 To num - 1
If ListBox1.Selected(i) = True Then
cnt = cnt + 1
For j = 0 To 6
a(cnt, j) = ListBox1.List()
MsgBox ("a(" & cnt & "," & j & ")= " & a(cnt, j))
Next

End If
Next


End Sub

I am trying to get the data from the selected items on a listbox in a
userform. The list box has 7 columns. When i select an item in the listbox,
I get a 'type mismatch' error. How do I collect the data from a selected
rows in a listbox?
Thanks

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 191
Default Listbox data

I tried that and that didn't work either. I am trying to get the values of
the row or rows that are selected in a listbox. I want to put these values
in a worksheet. I put in the 'msgbox' to see what value were being assigned
to 'a'. There are 7 columns in the listbox that I need to values from also.


"Joel" wrote:

I wasn't sure what value you wre looking for try this

a(cnt, j) = ListBox1.value

"ranswrt" wrote:

I changed it to 'a(cnt, j) = ListBox1.List(j)' , but the data in 'a' isn't
what I wanted. I am trying to get 'a' to get the data on a row that has been
selected on the listbox. There is 7 columns and i need data from each column
in 'a'. What am I doing wrong?
Thanks


"Joel" wrote:

The data in array a(1,0) is empty. I think you need the following change

from
a(cnt, j) = ListBox1.List()
to
a(cnt, j) = ListBox1.List(j)

"ranswrt" wrote:

I have the following code:

Private Sub ListBox1_Change()
Dim i As Integer
Dim cnt As Integer
Dim num As Integer
Dim j As Integer

num = ListBox1.ListCount
ReDim a(num, 7)
cnt = 0
For i = 0 To num - 1
If ListBox1.Selected(i) = True Then
cnt = cnt + 1
For j = 0 To 6
a(cnt, j) = ListBox1.List()
MsgBox ("a(" & cnt & "," & j & ")= " & a(cnt, j))
Next

End If
Next


End Sub

I am trying to get the data from the selected items on a listbox in a
userform. The list box has 7 columns. When i select an item in the listbox,
I get a 'type mismatch' error. How do I collect the data from a selected
rows in a listbox?
Thanks



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Listbox data


a(cnt, j) = ListBox1.listindex

"ranswrt" wrote:

I tried that and that didn't work either. I am trying to get the values of
the row or rows that are selected in a listbox. I want to put these values
in a worksheet. I put in the 'msgbox' to see what value were being assigned
to 'a'. There are 7 columns in the listbox that I need to values from also.


"Joel" wrote:

I wasn't sure what value you wre looking for try this

a(cnt, j) = ListBox1.value

"ranswrt" wrote:

I changed it to 'a(cnt, j) = ListBox1.List(j)' , but the data in 'a' isn't
what I wanted. I am trying to get 'a' to get the data on a row that has been
selected on the listbox. There is 7 columns and i need data from each column
in 'a'. What am I doing wrong?
Thanks


"Joel" wrote:

The data in array a(1,0) is empty. I think you need the following change

from
a(cnt, j) = ListBox1.List()
to
a(cnt, j) = ListBox1.List(j)

"ranswrt" wrote:

I have the following code:

Private Sub ListBox1_Change()
Dim i As Integer
Dim cnt As Integer
Dim num As Integer
Dim j As Integer

num = ListBox1.ListCount
ReDim a(num, 7)
cnt = 0
For i = 0 To num - 1
If ListBox1.Selected(i) = True Then
cnt = cnt + 1
For j = 0 To 6
a(cnt, j) = ListBox1.List()
MsgBox ("a(" & cnt & "," & j & ")= " & a(cnt, j))
Next

End If
Next


End Sub

I am trying to get the data from the selected items on a listbox in a
userform. The list box has 7 columns. When i select an item in the listbox,
I get a 'type mismatch' error. How do I collect the data from a selected
rows in a listbox?
Thanks

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 191
Default Listbox data

I tried 'a(cnt, j) = ListBox1.listindex' but that just assigned the row
number to 'a'. I am trying to get the values from each column is the row or
row's that was selected in the user for.


"Joel" wrote:


a(cnt, j) = ListBox1.listindex

"ranswrt" wrote:

I tried that and that didn't work either. I am trying to get the values of
the row or rows that are selected in a listbox. I want to put these values
in a worksheet. I put in the 'msgbox' to see what value were being assigned
to 'a'. There are 7 columns in the listbox that I need to values from also.


"Joel" wrote:

I wasn't sure what value you wre looking for try this

a(cnt, j) = ListBox1.value

"ranswrt" wrote:

I changed it to 'a(cnt, j) = ListBox1.List(j)' , but the data in 'a' isn't
what I wanted. I am trying to get 'a' to get the data on a row that has been
selected on the listbox. There is 7 columns and i need data from each column
in 'a'. What am I doing wrong?
Thanks


"Joel" wrote:

The data in array a(1,0) is empty. I think you need the following change

from
a(cnt, j) = ListBox1.List()
to
a(cnt, j) = ListBox1.List(j)

"ranswrt" wrote:

I have the following code:

Private Sub ListBox1_Change()
Dim i As Integer
Dim cnt As Integer
Dim num As Integer
Dim j As Integer

num = ListBox1.ListCount
ReDim a(num, 7)
cnt = 0
For i = 0 To num - 1
If ListBox1.Selected(i) = True Then
cnt = cnt + 1
For j = 0 To 6
a(cnt, j) = ListBox1.List()
MsgBox ("a(" & cnt & "," & j & ")= " & a(cnt, j))
Next

End If
Next


End Sub

I am trying to get the data from the selected items on a listbox in a
userform. The list box has 7 columns. When i select an item in the listbox,
I get a 'type mismatch' error. How do I collect the data from a selected
rows in a listbox?
Thanks

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Listbox data



a(cnt, j) = ListBox1.List(i, j)

"ranswrt" wrote:

I tried 'a(cnt, j) = ListBox1.listindex' but that just assigned the row
number to 'a'. I am trying to get the values from each column is the row or
row's that was selected in the user for.


"Joel" wrote:


a(cnt, j) = ListBox1.listindex

"ranswrt" wrote:

I tried that and that didn't work either. I am trying to get the values of
the row or rows that are selected in a listbox. I want to put these values
in a worksheet. I put in the 'msgbox' to see what value were being assigned
to 'a'. There are 7 columns in the listbox that I need to values from also.


"Joel" wrote:

I wasn't sure what value you wre looking for try this

a(cnt, j) = ListBox1.value

"ranswrt" wrote:

I changed it to 'a(cnt, j) = ListBox1.List(j)' , but the data in 'a' isn't
what I wanted. I am trying to get 'a' to get the data on a row that has been
selected on the listbox. There is 7 columns and i need data from each column
in 'a'. What am I doing wrong?
Thanks


"Joel" wrote:

The data in array a(1,0) is empty. I think you need the following change

from
a(cnt, j) = ListBox1.List()
to
a(cnt, j) = ListBox1.List(j)

"ranswrt" wrote:

I have the following code:

Private Sub ListBox1_Change()
Dim i As Integer
Dim cnt As Integer
Dim num As Integer
Dim j As Integer

num = ListBox1.ListCount
ReDim a(num, 7)
cnt = 0
For i = 0 To num - 1
If ListBox1.Selected(i) = True Then
cnt = cnt + 1
For j = 0 To 6
a(cnt, j) = ListBox1.List()
MsgBox ("a(" & cnt & "," & j & ")= " & a(cnt, j))
Next

End If
Next


End Sub

I am trying to get the data from the selected items on a listbox in a
userform. The list box has 7 columns. When i select an item in the listbox,
I get a 'type mismatch' error. How do I collect the data from a selected
rows in a listbox?
Thanks

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 191
Default Listbox data

Thanks
That worked

"Joel" wrote:



a(cnt, j) = ListBox1.List(i, j)

"ranswrt" wrote:

I tried 'a(cnt, j) = ListBox1.listindex' but that just assigned the row
number to 'a'. I am trying to get the values from each column is the row or
row's that was selected in the user for.


"Joel" wrote:


a(cnt, j) = ListBox1.listindex

"ranswrt" wrote:

I tried that and that didn't work either. I am trying to get the values of
the row or rows that are selected in a listbox. I want to put these values
in a worksheet. I put in the 'msgbox' to see what value were being assigned
to 'a'. There are 7 columns in the listbox that I need to values from also.


"Joel" wrote:

I wasn't sure what value you wre looking for try this

a(cnt, j) = ListBox1.value

"ranswrt" wrote:

I changed it to 'a(cnt, j) = ListBox1.List(j)' , but the data in 'a' isn't
what I wanted. I am trying to get 'a' to get the data on a row that has been
selected on the listbox. There is 7 columns and i need data from each column
in 'a'. What am I doing wrong?
Thanks


"Joel" wrote:

The data in array a(1,0) is empty. I think you need the following change

from
a(cnt, j) = ListBox1.List()
to
a(cnt, j) = ListBox1.List(j)

"ranswrt" wrote:

I have the following code:

Private Sub ListBox1_Change()
Dim i As Integer
Dim cnt As Integer
Dim num As Integer
Dim j As Integer

num = ListBox1.ListCount
ReDim a(num, 7)
cnt = 0
For i = 0 To num - 1
If ListBox1.Selected(i) = True Then
cnt = cnt + 1
For j = 0 To 6
a(cnt, j) = ListBox1.List()
MsgBox ("a(" & cnt & "," & j & ")= " & a(cnt, j))
Next

End If
Next


End Sub

I am trying to get the data from the selected items on a listbox in a
userform. The list box has 7 columns. When i select an item in the listbox,
I get a 'type mismatch' error. How do I collect the data from a selected
rows in a listbox?
Thanks

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
Populating listbox with only one data [email protected] Excel Programming 1 July 20th 07 10:28 PM
Loading Data into ListBox [email protected] Excel Programming 3 February 1st 07 06:40 AM
VBA: Creating listbox similar to the one in Pivot table (Listbox+Checkbox) modjoe23 Excel Programming 3 August 18th 05 02:35 PM
listbox.value not equal to listbox.list(listbox.listindex,0) ARB Excel Programming 0 October 22nd 03 12:46 AM
Adding a row of data to a Listbox Scott Elrod[_2_] Excel Programming 0 August 27th 03 09:43 PM


All times are GMT +1. The time now is 10:44 AM.

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

About Us

"It's about Microsoft Excel"