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

With Worksheets("Wkly Renewals").ListBox1
For LstBxItem = 0 To .ListCount - 1
If .Selected(LstBxItem) Then
MsgBox .List(LstBxItem)
MsgBox LstBxItem.Value
end with
When it hits the line MsgBox .List(LstBxItem) it displays
the value. In this case its index item 0 so it displays
the index item 0 which is the value "Jan Week 1" When it
gets to the MsgBox LstBxItem.Value line, I get the error
Runtime error 424 object required.

Why is this?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Listbox Index Problem

Todd,

LstBxItem is an integer or long, not an object, and thus does not
have a Value property. This would be clear if you explicitly
declare your variables.

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Todd Huttenstine" wrote in
message ...
With Worksheets("Wkly Renewals").ListBox1
For LstBxItem = 0 To .ListCount - 1
If .Selected(LstBxItem) Then
MsgBox .List(LstBxItem)
MsgBox LstBxItem.Value
end with
When it hits the line MsgBox .List(LstBxItem) it displays
the value. In this case its index item 0 so it displays
the index item 0 which is the value "Jan Week 1" When it
gets to the MsgBox LstBxItem.Value line, I get the error
Runtime error 424 object required.

Why is this?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 260
Default Listbox Index Problem

Ok I didnt know that. The value of .List(LstBxItem) was
what I needed for the pivot table data field and I was
wondering why the pivot table couldnt see this value. I
was using the msgbox to try and help me figure it out. So
what I did was set the variable PvtLstBxItem = .List
(LstBxItem). This way it was converted I guess to an
object??? I then used that variable in the pivot table
code and it worked. below is the code I used...


With Worksheets("Wkly Renewals").ListBox1
For LstBxItem = 0 To .ListCount - 1
If .Selected(LstBxItem) Then
PvtCounter = PvtCounter + 1
PvtLstBxItem = .List(LstBxItem)
MsgBox PvtLstBxItem

With ActiveSheet.PivotTables("PivotTable4").PivotFields
(PvtLstBxItem)
.Orientation = xlDataField
.Caption = PvtLstBxItem
.Position = PvtCounter
.Function = xlSum
End With

End If
Next LstBxItem
End With

-----Original Message-----
Todd,

LstBxItem is an integer or long, not an object, and thus

does not
have a Value property. This would be clear if you

explicitly
declare your variables.

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Todd Huttenstine"

wrote in
message ...
With Worksheets("Wkly Renewals").ListBox1
For LstBxItem = 0 To .ListCount - 1
If .Selected(LstBxItem) Then
MsgBox .List(LstBxItem)
MsgBox LstBxItem.Value
end with
When it hits the line MsgBox .List(LstBxItem) it

displays
the value. In this case its index item 0 so it

displays
the index item 0 which is the value "Jan Week 1" When

it
gets to the MsgBox LstBxItem.Value line, I get the error
Runtime error 424 object required.

Why is this?



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Listbox Index Problem

Todd,

LstBxItem is just a index variable, it doesn't have a value property. What
are you trying to show with the second MsgBox, as it seems you are trying to
show the same thing to me. If you want the in dex itself, just use

Msgbox LstBxItem

maybe plus 1 if yhou don 't want it starting at 0

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Todd Huttenstine" wrote in message
...
With Worksheets("Wkly Renewals").ListBox1
For LstBxItem = 0 To .ListCount - 1
If .Selected(LstBxItem) Then
MsgBox .List(LstBxItem)
MsgBox LstBxItem.Value
end with
When it hits the line MsgBox .List(LstBxItem) it displays
the value. In this case its index item 0 so it displays
the index item 0 which is the value "Jan Week 1" When it
gets to the MsgBox LstBxItem.Value line, I get the error
Runtime error 424 object required.

Why is this?



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
Problem using INDEX to select items in listbox Shazbot Excel Discussion (Misc queries) 3 April 28th 06 09:06 AM
Listbox Problem browie Excel Discussion (Misc queries) 5 August 22nd 05 02:03 PM
listbox.value not equal to listbox.list(listbox.listindex,0) ARB Excel Programming 0 October 22nd 03 12:46 AM
Filling a listbox depending on font index Trevor[_3_] Excel Programming 0 October 1st 03 08:25 PM
Listbox problem Stuart[_5_] Excel Programming 6 August 18th 03 09:14 PM


All times are GMT +1. The time now is 02:41 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"