object required error

thechipper1982

New Member
Joined
Jun 2, 2011
Messages
7
I can not figure out why I am getting this error. Any help would be great!

Here is my code:

Code:
Sub SaveOrder()

Sheets("ORDERS").Select
Range("A6").Select

Dim rownum As Long
Dim First As String
Dim Last As String
Dim Invoice As String
Dim MyDate As String
Dim findinvoice As String

Do While Not IsEmpty(ActiveCell)
ActiveCell.Offset(1, 0).Select
Loop
     
rownum = ActiveCell.Row
    
        Application.EnableEvents = False
        On Error Resume Next
      
  With Sheets("ORDERS")
      
            Set findinvoice = .Range("U:U").Find(Invoice, LookIn:=xlValues, LookAt:=xlWhole)

I get the error on the very last line with my string findinvoice.

I can not even get any part of the code to work, if I try to step into it, it stops at the very top and highlights findinvoice as the problem.

Not sure what to do.

chip.
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Welcome to the forum!

AlphaFrog spotted the problem.
 
Last edited:
Upvote 0
thanks for the help.

that makes sense.

so the Set will return a cell reference?

I am trying to search through column U for the value stored in "Invoice". And if it finds that value then I want to set "findinvoice" to the value of that cell.

if I just change findinvoice to Range, will that allow me to set the cell's value to what I find in the cell?

thanks for help!

chip.
 
Upvote 0
This finds the cell that matches the Invoice value.
Code:
    With Sheets("ORDERS")
        Set findinvoice = .Range("U:U").Find(Invoice, LookIn:=xlValues, LookAt:=xlWhole)
    End With


findinvoice is that matched cell. If the match was found in say "U10", then findinvoice is cell U10.

Once findinvoice is Set, you can treat it just like any Range object. You can change the value of findinvoice with somthing like...

Code:
findinvoice.Value = "XYZ123"
 
Upvote 0
can I say something like:

findvalue.select
if activecell.value = Invoice then
yadda yadda yadda
end if

should this work?

thanks

chip.
 
Upvote 0

Forum statistics

Threads
1,224,607
Messages
6,179,871
Members
452,948
Latest member
UsmanAli786

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