LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Run time error '1004'

Hi, I have written a small piece of code to populate 2 listboxes on an excel
worksheet. The code works fine when run in later versions of Excel (2000),
but when run in Excel 97 (which the majority of the users will be running) I
receive the following run time error;

Rumtime error '1004'
Unable to get the find property of the range class.

If I debug the program it seems to be the following piece of code which is
generating the error;

Rw1 = ws.Columns(2).Find(Me.ListBox1.Value, lookat:=xlWhole).Row

The whole of my code looks like;

Private Rw1 As Long, Rw2 As Long

Private Sub Worksheet_Activate()
Dim ws As Worksheet, r As Range, i As Integer, Header() As String
Set ws = Sheets("sheet2")
With ws
For Each r In .Range("b6,b19,b26,b49,b56,b83,b89,b96")
ReDim Preserve Header(i)
Header(i) = r.Value: i = i + 1
Next
End With
Me.ListBox1.List() = Header
End Sub

Private Sub ListBox1_Change()
Dim ws As Worksheet, a, x
x = Me.ListBox1.ListIndex
Set ws = Sheets("sheet2")
With ws
Rw1 = ws.Columns(2).Find(Me.ListBox1.Value, lookat:=xlWhole).Row
If Me.ListBox1.ListIndex < Me.ListBox1.ListCount - 1 Then
x = Me.ListBox1.List(x + 1)
Rw2 = ws.Columns(2).Find(what:=x, lookat:=xlWhole).Row
Else
Rw2 = ws.Range("b65536").End(xlUp).Row + 1
End If
a = .Range(.Cells(Rw1 + 1, "b"), .Cells(Rw2 - 1, "b")).Value
End With
Me.ListBox2.List = a
Erase a
End Sub

Private Sub ListBox2_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Dim r As Range, ws As Worksheet
Set ws = Sheets("sheet2")
With ws
Set r = .Range(.Cells(Rw1 + 1, "b"), .Cells(Rw2 - 1,
"b")).Find(what:=Me.ListBox2.Value, lookat:=xlWhole)
If Not r Is Nothing Then
Set r = r.Resize(, 3)
Me.Range("c65536").End(xlUp).Offset(1).Resize(, 3).Value = r.Value
End If
End With
End Sub

Sheet2 contains a list of items under headings. On sheet1, Listbox1 displays
all of the headings and then when a heading is selected displays all of the
data for that header in Listbox2, then each item form Listbox2 can be double
clicked and entered into the last free cell on Sheet1. The program works
perfect in Excel 2000, which is what it was written in, unfortunately many of
the users will be running Excel 97.

Any help with this issue would be much appreciated as I have trawled every
article I can find on this issue.

Regards

Jon Keane

P.S If anybody should wish to look at the Excel workbook in question, I have
made it available @
http://www.hillsdata.co.uk/public/jo...untime_err.xls

 
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, General ODBC error [email protected] New Users to Excel 0 September 19th 05 01:41 AM
Run-time error '1004' David Excel Programming 8 May 28th 05 04:49 AM
Run time error '1004': Generaol ODBC error Dwaine Horton[_3_] Excel Programming 2 April 26th 05 02:52 PM
Run time error 1004 General ODCB Error Kevin Excel Programming 3 February 26th 05 12:51 PM
Application Run Time Error 1004 and Stack Error ExcelMonkey[_190_] Excel Programming 9 February 11th 05 04:48 PM


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