VBA Run-time error '91' on Find string variable

sarkocreme

New Member
Joined
Dec 14, 2009
Messages
9
Code:
Range("A10").Select
dateselect = Selection.Text
Range("A10:B30").Select
    Selection.Copy
Windows("Products.xlsx").Activate
Sheets("Year").Select
Cells.Find(What:=dateselect, After:=ActiveCell, LookIn:=xlFormulas, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Activate

Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False

I'm getting a "run-time error '91': Object variable or With block variable not set" and the Cells.Find part is being highlighted. What's the issue?
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Short answer: = It didn't find what it was looking for.

Long Answer: = Give some detail about what you want the macro to do...
It's likely that since you set dateselect = selection.TEXT, but it's looking for a DATE on the other sheet, it won't find it. Because it's different type of value.
try changing

dateselect = Selection.Text
to
dateselect = Selection.Value
 
Upvote 0

Forum statistics

Threads
1,214,998
Messages
6,122,638
Members
449,093
Latest member
Ahmad123098

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