Error 400 (1004 in Debug)

dunemight

New Member
Joined
Mar 27, 2017
Messages
2
Hi there,

So happy I found this forum of experts. Hopefully someone can help diagnose this error.

Code:
Sub TransactionIndex()
    
    Dim Index As Long
    Dim Current As Range
    Dim Row As Range
    
    Index = 1
    Set Current = Worksheets("Test").Range("D2")
    
    Set Row = Worksheets("Test").Range(Current.Address, "D" & Last_Row()).Find("TRUE", LookIn:=xlValues, After:=Range(Current.Address))
    
    If Not Row Is Nothing Then
        Worksheets("Test").Range("C" & Row.Row).Value = Index
        Index = Index + 1
    End If
    
    Do While Not Row Is Nothing
        Set Row = Worksheets("Test").Range(Current, "D" & Last_Row()).Find("FALSE", After:=Range(Row))
        Set Current = Row
    
        Set Row = Worksheets("Test").Range(Current, "D" & Last_Row()).Find("TRUE", After:=Range(Current.Address))
        Worksheets("Test").Range("C" & Row.Row).Value = Index
        Index = Index + 1
    Loop
    
End Sub

Thanks!
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Oh I forgot this.

Code:
Function Last_Row() As Long
    Dim sht As Worksheet
    
    Set sht = Worksheets("Sample Data")
    
    Last_Row = sht.Cells(sht.Rows.Count, "A").End(xlUp).Row


End Function

The value returned is 39278.

The error seems to stem from
Code:
Set Row = Worksheets("Test").Range(Current, "D" & Last_Row()).Find("FALSE", After:=Range(Row))
 
Upvote 0

Forum statistics

Threads
1,214,567
Messages
6,120,268
Members
448,953
Latest member
Dutchie_1

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