Need help with an Application.Match line that uses variables to define everything

RainbowGurl44

New Member
Joined
May 29, 2013
Messages
3
Hi, all!

I'm a total newbie at VBA, and I'm trying to get this code to use some pre-defined variables to accurately define a range of cells within a column. This range is going to keep changing... there's a loop.

If the code looks messy, that's probably due to my efforts to split everything up in the hopes of isolating the problem.

Code:
For Each ATA In MyRange

Set NextATA = ATA.Offset(1, 0)
'Has it go through each ATA in the list, one at a time, creating a workbook for each one.

'STILL NEED TO FIX THIS PART BELOW.


Set RepairListRange = Workbooks("Estimate Sheet Template.xlsx").Worksheets("STICK CONVERTED PDF HERE").Range("D1:D3000")
Set RepairListFirst = Application.Match(ATA.Value), Range("RepairListRange"), False)
RepairListFirst = RepairListFirst + 1
Set RepairListLast = Application.Match(NextATA.Value, Range("RepairListRange"), False)
RepairListLast = RepairListLast - 1
Set RepairList = "D" + RepairlistFirstRow + ":D" + RepairListLast

The preceding variable declarations are:

Code:
Public ATA As Range, MyRange As Range
Public NextATA As Range
Public RepairList As Range
Public RepairListFirst As Variant
Public RepairListLast As Variant
Public RepairListRange As Range
Public Repair As Range

The error code I've been getting is: Run-time error '13': Type mismatch. I've been trying putting things in quotes, and out of quotes, using '0' instead of 'False'... And I'm still feeling really stuck!

Thanks, everyone!
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
To clarify, it's the

Code:
Set RepairListFirst = Application.Match(ATA.Value), Range("RepairListRange"), False)

line that it's getting stuck on.

Thanks!
 
Upvote 0
So, coming back to it the next day, I found that there were layers to the issue! I fixed one of them: The sub wasn't using the Public declarations that preceded it, so nothing was actually getting defined. But upon fixing that (I think!), now I'm getting an "Object Required" error for the same line. Let me know if more information is required! Thanks!
 
Upvote 0

Forum statistics

Threads
1,215,219
Messages
6,123,680
Members
449,116
Latest member
HypnoFant

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