Hi all
I want to check value in textbox1 in form(CDKT) with sheet("nb","ngb"). If found will copy row to sheet(ky1) and Ihave code below
Code yelow at line: Set ans1 = TextBox1.Value
And have VBA notice: "Object require"
Please help me correct this code, thanks
I want to check value in textbox1 in form(CDKT) with sheet("nb","ngb"). If found will copy row to sheet(ky1) and Ihave code below
Code yelow at line: Set ans1 = TextBox1.Value
And have VBA notice: "Object require"
Please help me correct this code, thanks
Code:
Sub Filter()Application.ScreenUpdating = False
Sheets("ky1").Cells.clear
Dim Lastrowa1 As Long, Lastrowa2 As Long, Lastrow1 As Long, Lastrow2 As Long
Dim ans1 As Long
Lastrowa1 = Sheets("nb").Cells(Rows.Count, "A").End(xlUp).Row
Lastrowa2 = Sheets("ngb").Cells(Rows.Count, "A").End(xlUp).Row
Lastrow1 = Sheets("ky1").Cells(Rows.Count, "A").End(xlUp).Row
CDKT.Show
[COLOR=#ff0000]Set ans1 = TextBox1.Value[/COLOR]
With Sheets("nb").Range("A1:A" & Lastrowa1)
.AutoFilter Field:=1, Criteria1:="*" & ans1 & "*", Operator:=xlOr, Criteria2:=ans1
.Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlCellTypeVisible).EntireRow.Copy Worksheets("ky1").Range("A" & Lastrowd + 1)
.AutoFilter
.AutoFilter Field:=1, Criteria1:="*" & ans2 & "*", Operator:=xlOr, Criteria2:=ans2
.Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlCellTypeVisible).EntireRow.Copy Worksheets("ky1").Range("A" & Lastrowd + 1)
.AutoFilter
End With
Application.ScreenUpdating = True
End Sub