Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default VBA Find produces 1004 error

I have this code :-

Private Sub CommandButton1_Click()

Dim FW As Variant
Dim rngCell As Range

FW = Worksheets("LU").Cells(1, 1).Value

With Worksheets("Detail")
Set rngCell = .Cells.Find(What:=FW, _
After:=.Cells(1, 1), LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)
End With

If Not rngCell Is Nothing Then
MsgBox rngCell.Row
End If

End Sub

Worksheets("LU").Cells(1, 1) contains value "109435"

When running I get error "Run-time error 1004 - Unable to get the Find
Property of the Range Class"

Any ideas?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default VBA Find produces 1004 error

If you using Excel 97, then change the takefocusonClick property of the
commandbutton to false.

--
Regards,
Tom Ogilvy



"Andy" wrote:

I have this code :-

Private Sub CommandButton1_Click()

Dim FW As Variant
Dim rngCell As Range

FW = Worksheets("LU").Cells(1, 1).Value

With Worksheets("Detail")
Set rngCell = .Cells.Find(What:=FW, _
After:=.Cells(1, 1), LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)
End With

If Not rngCell Is Nothing Then
MsgBox rngCell.Row
End If

End Sub

Worksheets("LU").Cells(1, 1) contains value "109435"

When running I get error "Run-time error 1004 - Unable to get the Find
Property of the Range Class"

Any ideas?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default VBA Find produces 1004 error

Thanks Tom - As always that solved the problem

Trouble is, when the error was fixed it should have found that value as it
does exist in the 'Detail' worksheet but I found that Range rngCell was set
to Nothing following execution of line of code with ethe Find statament.

"Tom Ogilvy" wrote:

If you using Excel 97, then change the takefocusonClick property of the
commandbutton to false.

--
Regards,
Tom Ogilvy



"Andy" wrote:

I have this code :-

Private Sub CommandButton1_Click()

Dim FW As Variant
Dim rngCell As Range

FW = Worksheets("LU").Cells(1, 1).Value

With Worksheets("Detail")
Set rngCell = .Cells.Find(What:=FW, _
After:=.Cells(1, 1), LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)
End With

If Not rngCell Is Nothing Then
MsgBox rngCell.Row
End If

End Sub

Worksheets("LU").Cells(1, 1) contains value "109435"

When running I get error "Run-time error 1004 - Unable to get the Find
Property of the Range Class"

Any ideas?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default VBA Find produces 1004 error

assume that value is in cell B9 in detail and obviously A1 in LU.

In B1 of LU put in the formula (or in any blank cell in LU)

=A1=Detail!B9

does it return true. If not, figure out why not.

--
Regards,
Tom Ogilvy


"Andy" wrote:

Thanks Tom - As always that solved the problem

Trouble is, when the error was fixed it should have found that value as it
does exist in the 'Detail' worksheet but I found that Range rngCell was set
to Nothing following execution of line of code with ethe Find statament.

"Tom Ogilvy" wrote:

If you using Excel 97, then change the takefocusonClick property of the
commandbutton to false.

--
Regards,
Tom Ogilvy



"Andy" wrote:

I have this code :-

Private Sub CommandButton1_Click()

Dim FW As Variant
Dim rngCell As Range

FW = Worksheets("LU").Cells(1, 1).Value

With Worksheets("Detail")
Set rngCell = .Cells.Find(What:=FW, _
After:=.Cells(1, 1), LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)
End With

If Not rngCell Is Nothing Then
MsgBox rngCell.Row
End If

End Sub

Worksheets("LU").Cells(1, 1) contains value "109435"

When running I get error "Run-time error 1004 - Unable to get the Find
Property of the Range Class"

Any ideas?

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
Refresh produces #N/A error RhysPieces Links and Linking in Excel 1 July 11th 07 07:42 PM
Refresh produces #N?A error RhysPieces Excel Discussion (Misc queries) 1 July 10th 07 09:16 AM
Input box cancel produces error pkeegs Excel Programming 5 April 12th 06 06:05 AM
Sorting a 2 column list with VBA using Worksheet change produces 1004 error Casey[_10_] Excel Programming 3 June 28th 04 04:38 PM
CreateObject produces error Robert Chapman Excel Programming 0 August 15th 03 03:48 PM


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