Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 238
Default Run-time-error 1004 "ListIndex method of listbox class failed"

I am getting Run-time-error 1004 "ListIndex method of listbox
class failed"

It stops at
ListIndex = RowNo ' Error
using excel 97. It was written in excel 2000 and works fine in 2007. I
was testing it with 97 and it I get this error.
I changed From
.ListIndex = RowNo
to
For .ListIndex = 1
Still fails. Is this one of those commands that did not exist in this
for in 97 version.
_________________________________________________

Sub aSlideShow()
Worksheets("Sheet2").Select
With Worksheets("Sheet2").Shapes("List Box 1").OLEFormat.Object
Sheets("Sheet4").Range("AH20").Value = .ListCount
AddressNo = "initial"
'MsgBox .ListCount
For RowNo = 1 To .ListCount

..ListIndex = RowNo ' Error

AddressNo = .List(.ListIndex)
If AddressNo = "" Or AddressNo = " " Then 'Detect blank
.ListIndex = 1
Call ListBoxAuto
Exit Sub
End If
Application.Wait (Now + TimeValue("0:00:01") / 2)
OpenForms = DoEvents
Call ListBoxAuto
'On Error GoTo Finis
Next RowNo
End With
Finis:
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 82
Default Run-time-error 1004 "ListIndex method of listbox class failed"

What type of listbox is it?

The code shouldn't really work in any version of Excel, ListCount is a
count of the items in a listbox.

The index of a listbox is zero-based, eg item 1 - listindex = 0, item
2 - listindex etc...

So there is no item with the index equal to the ListCount, the last
item's index is list count minus one.


Try this:

For RowNo = 0 To .ListCount-1

or

For RowNo = 1 To .ListCount
....

..ListInde = RowNo-1
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
"run-time error '1004' - select method of range failed" maemi weirdoke Excel Programming 2 March 5th 08 03:15 PM
Run-time error "1004" Select method of range class failed Tallan Excel Discussion (Misc queries) 3 March 7th 07 05:22 PM
VBA error 1004 "Select method of Range class failed" Matt J Excel Programming 6 July 3rd 04 10:05 PM
Error 1004, "select method of range class failed" paritoshmehta[_11_] Excel Programming 3 May 6th 04 10:09 PM
Runtime Error "1004" Select Method of Range Class Failed Stephen[_7_] Excel Programming 4 April 10th 04 06:28 AM


All times are GMT +1. The time now is 03:06 AM.

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"