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

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
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,223,229
Messages
6,170,881
Members
452,364
Latest member
springate

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