user3181985
user3181985

Reputation: 11

Excel Worksheet function match doesn't work?

I have a date in sheet 'dashboard' M1. and I need to match this in a range in 'HDCinput' cells A33:A833. When I run the below code (part of a bigger macro) I get a "Object variable or With block variable not set". I'm not sure why

Dim mydate As Date
Dim myrange As Range
Dim Colindex As Long

mydate = Sheets("Dashboard").Range("M1")
myrange = Sheets("HDCInput").Range("A3:A833")
Colindex = Application.WorksheetFunction.Match(mydate, myrange, 0)

Upvotes: 0

Views: 288

Answers (1)

EngJon
EngJon

Reputation: 987

You have to Set Range Objects:

Set myrange = Sheets("HDCInput").Range("A3:A833")

Not further tested, but this should solve that particular error.

Upvotes: 1

Related Questions