Runtime error '1004' application-defined or object-defined error

Pookiemeister

Well-known Member
Joined
Jan 6, 2012
Messages
563
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
What I would like the code below to do is find the value of the variable "str" then place the value of the textbox called "TxtBxBlkBlnd" inside Range(found.row, "Column Letter Here") but I keep getting that same Runtime error '1004'. Would someone mind explaining what this error means in simple (non-technical terms) please, and also an easy way (if any) to resolve it. To me, I think it means it can't find that location. The error occurs on all the lines that have this code regardless of the Column letter.

Code:
Range(found.Row, "H") = Me.TxtBxBlkBlnd.Value


Code:
Select Case True        
        Case Is = optSlat
            Workbooks("F-103-04 Exh E-Bulk MT-Pkg Prod Theoretical Yield Report-Rev004_ver_19_5.xlsm").Activate
            Set found = Worksheets("Product_Info").Range("A3", Range("A" & Rows.Count).End(xlUp)).Find(str)
            Range(found.Row, "D") = Me.TxtBxBlkBlnd.Value
        Case optUhlmann2
            Workbooks("F-103-04 Exh E-Bulk MT-Pkg Prod Theoretical Yield Report-Rev004_ver_19_5.xlsm").Activate
            Set found = Worksheets("Product_Info").Range("E3", Range("E" & Rows.Count).End(xlUp)).Find(str)
            Range(found.Row, "H") = Me.TxtBxBlkBlnd.Value
        Case Is = optKorber
            Workbooks("F-103-04 Exh E-Bulk MT-Pkg Prod Theoretical Yield Report-Rev004_ver_19_5.xlsm").Activate
            Set found = Worksheets("Product_Info").Range("I3", Range("I" & Rows.Count).End(xlUp)).Find(str)
            Range(found.Row, "L") = Me.TxtBxBlkBlnd.Value
        Case Is = optIMA
            Workbooks("F-103-04 Exh E-Bulk MT-Pkg Prod Theoretical Yield Report-Rev004_ver_19_5.xlsm").Activate
            Set found = ActiveSheet.Range("M3", Range("M" & Rows.Count).End(xlUp)).Find(str)
            ActiveSheet.Range(found.Row, "P") = TxtBxBlkBlnd.Value
        Case optUhlmann5
            Workbooks("F-103-04 Exh E-Bulk MT-Pkg Prod Theoretical Yield Report-Rev004_ver_19_5.xlsm").Activate
            Set found = Worksheets("Product_Info").Range("Q3", Range("Q" & Rows.Count).End(xlUp)).Find(str)
            Range(found.Row, "T") = Me.TxtBxBlkBlnd.Value
        Case optPouch
            Workbooks("F-103-04 Exh E-Bulk MT-Pkg Prod Theoretical Yield Report-Rev004_ver_19_5.xlsm").Activate
            Set found = Worksheets("Product_Info").Range("U3", Range("U" & Rows.Count).End(xlUp)).Find(str)
            Range(found.Row, "X") = Me.TxtBxBlkBlnd.Value
    End Select

Thank You
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
It means that the compiler has detected something in the statement that does not meet the criteria for a trappable error but also cannot be processed logically. In most cases it is a user generated condition like misspelled words or omitted definitions. It can also be variables that do not contain a value or reference to a wrong sheet. In your statement for example, Range is unqualified to a specific sheet, so it will revert to the active sheet. If you use the mouse pointer to hover over the variables in the statement when the error occurs and you click 'Debug', it will show what values the variables hold. You can use a statement like:

Code:
If Not found Is Nothing Then
    Range(found.Row, "X") = Me.TxtBxBlkBind.Value
Else
    MsgBox str & " Not Found"
End If

that will avoid the error if the varable value is not found and display a message.
 
Last edited:
Upvote 0
How are you using Range here? What do you expect to get with Range(found.Row,"D")? Assuming you know what 'found.Row' is, pretend it is 7. Now we have Range(7,"D"). What does that mean? I would understand Range("D" & found.Row). Thanks for the explanation.
 
Upvote 0
@Pookimeister, what do you get with

Code:
Cells(found.Row, "H") = Me.TxtBxBlkBlnd.Value

rather than

Code:
Range(found.Row, "H") = Me.TxtBxBlkBlnd.Value
 
Upvote 0
@Pookimeister, what do you get with

Code:
Cells(found.Row, "H") = Me.TxtBxBlkBlnd.Value

rather than

Code:
Range(found.Row, "H") = Me.TxtBxBlkBlnd.Value

And Cells still needs to be qualified with a parent sheet unless the user wants it to refer to the active sheet.
 
Upvote 0
And Cells still needs to be qualified with a parent sheet unless the user wants it to refer to the active sheet.

Yes it does if it isn't referring to the Active Sheet, but as the OP has given no indication that it isn't referring to the active sheet then the code I posted is correct with the information given whereas Range(found.Row, "H") is incorrect syntax and will by itself give a 1004 error (although it should give a range of object error).

I am taking it one step at a time until we get enough information and the first step is getting the basic syntax correct :biggrin:
 
Upvote 0

Forum statistics

Threads
1,215,102
Messages
6,123,097
Members
449,096
Latest member
provoking

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top