0

I don't have much VBA experience at all, but this is what I'm trying to do (code is below):

I have two sheets- one of dies, one of sales. Each sale has a die it comes from, with a many sales to one die relationship. I'd like to loop through all dies, and within that loop loop through all sales, and compare each of the rows to a set of criteria before outputting them.

'All dies have a type and a size. All products have a type and a size. We hope to match them.
Sub searchroute()
Dim x As Integer, y As Integer, z As Integer
x = 0 'for row offset on dies, number
y = 0 'for row offset on sales, item
z = 0 'for later use

Do Until IsEmpty(Worksheets("Dies").a2.Offset(x, 0)) = True
    Do Until IsEmpty(Worksheets("Sales").a2.Offset(y, 0)) = True
        If Worksheets("Dies").i2.Offset(x, 0) = Worksheets("Sales").c2.Offset(y, 0) Or Worksheets("Dies").i2.Offset(x, 0) = "Any" Then
            If Worksheets("Sales").g2.Offset(y, 0) = Worksheets("Dies").j2.Offset(x, 0) Or Worksheets("Dies").j2.Offset(x, 0) = "Any" Then
                'then we've got the same type and size, print output to a cell
                'should figure out how to append, place the whole list in a single cell
            End If
        End If
        y = y + 1
    Loop
    x = x + 1
Loop

End Sub

Stepping through this, it pops a 438 error on the first Do Until. I know this is something easy, but my mind is blank.

Thanks in advance for wisdom!

1
  • Why are you tryin to offset the column/rows? Try Do Until IsEmpty(Worksheets("Dies").range("A2").Offset(x, 0)) = True Or something along he lines of that. Your issue stems from a lack of a range object I think. Commented Jul 29, 2013 at 19:09

1 Answer 1

3

Replace Worksheets("Dies").a2. with Worksheets("Dies").Range("a2").

Same goes for all instances where you are trying to refer to a spcific cell.

Sign up to request clarification or add additional context in comments.

1 Comment

not even close to the stupidest mistake I've ever made... ;-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.