Receiving 'Error 1004' with VBA program

S

shawn.hobbs

I am writing a VBA that allows the user to scan or enter an item on
lines in a spreadsheet. If the UPC is not valid, it triggers a
Userform that let's the user to input a description to find the item
in question instead of a UPC.

The problem I am having is in the programming linking the Userform
description to the find formula. If there is a match, the program
continues fine; however, if there is no match, the program issues an
'Error 1004' and stalls at the following line:

If IsError(Sheet6.Range("L2").Formula =
Application.WorksheetFunction.IsNumber(Application.WorksheetFunction.Find(frmMatchDescriptions.txtEnterDescription,
Sheet6.Range("L2").Offset(0, -9).Value))) Then

Sheet6.Range("L2").Value = False

Else

Sheet6.Range("L2").Formula =
Application.WorksheetFunction.IsNumber(Application.WorksheetFunction.Find(frmMatchDescriptions.txtEnterDescription,
Sheet6.Range("L2").Offset(0, -9).Value))

End If


Please tell me what is wrong and how I can correct this?

Thank you,
Shawn
 
J

Joel

I think you may be setting an item to a formula that can't be asigned to the
formula. You need to break your code up into small pieces

Sub test()

Set c =
Application.WorksheetFunction.Find(frmMatchDescriptions.txtEnterDescription, _
Sheet6.Range("L2").Offset(0, -9).Value)

If Not c Is Nothing Then
If Application.WorksheetFunction.IsNumber(c) Then
Sheet6.Range("L2").Formula = c
Else
Sheet6.Range("L2").Value = False
End If
End If

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top