I'm trying to filter column A with specified keywords then fill some text in visible cell of column B using "Sub RunThis"
Once my keyword not match with any of rows A then the error1004 appear.
Could you please suggest me to fix this ?
Thank you so much,
My working file: https://www.dropbox.com/s/k4tnw9fsnv...heet.xlsm?dl=0
My cross-posting
http://stackoverflow.com/questions/3...out-1004-error
http://www.excelforum.com/showthread...5681&p=4088366
http://www.ozgrid.com/forum/showthread.php?t=195012
VB:
Public LastRow As Long
Sub RunThis()
LastRow = ActiveCell.SpecialCells(xlCellTypeLastCell).Row
'Suite1
'Suite2
'Suite3
'Suite4
'Suite5
Suite6
'Suite7
'Suite8
'Suite9
'Suite10
'Suite11
End Sub
'==============================FIND===Suite6==================
Sub Suite6()
On Error Goto NEXT0
'============Search KeyWord 1 2
ActiveSheet.Range("A:A").AutoFilter Field:=1, Criteria1:= _
"=*S6R*", Operator:=xlOr, Criteria2:="=*Suite6/*"
' Select target column to paste
Range("D2:D" & LastRow).Select
Selection.SpecialCells(xlCellTypeVisible).Select
' TargetText for this search
Selection.FormulaR1C1 = "Suite-6"
NEXT0:
On Error Goto NEXT2
ActiveSheet.Range("A:A").AutoFilter Field:=1, Criteria1:= _
"=*Suite 6/*", Operator:=xlOr, Criteria2:="=*Suite_6/*"
' Select target column to paste
Range("D2:D" & LastRow).Select
Selection.SpecialCells(xlCellTypeVisible).Select
' TargetText for this search
Selection.FormulaR1C1 = "Suite-6"
NEXT2:
On Error Goto NEXT3
ActiveSheet.Range("A:A").AutoFilter Field:=1, Criteria1:= _
"=*Suite-6/*", Operator:=xlOr, Criteria2:="=*Suite6.*"
' Select target column to paste
Range("D2:D" & LastRow).Select
Selection.SpecialCells(xlCellTypeVisible).Select
' TargetText for this search
Selection.FormulaR1C1 = "Suite-6"
NEXT3:
On Error Goto NEXT4
ActiveSheet.Range("A:A").AutoFilter Field:=1, Criteria1:= _
"=*Suite 6.*", Operator:=xlOr, Criteria2:="=*Suite_6.*"
' Select target column to paste
Range("D2:D" & LastRow).Select
Selection.SpecialCells(xlCellTypeVisible).Select
' TargetText for this search
Selection.FormulaR1C1 = "Suite-6"
NEXT4:
On Error Goto NEXT5
ActiveSheet.Range("A:A").AutoFilter Field:=1, Criteria1:= _
"=*Suite-6.*", Operator:=xlOr, Criteria2:="=*Suite-6/*"
' Select target column to paste
Range("D2:D" & LastRow).Select
Selection.SpecialCells(xlCellTypeVisible).Select
' TargetText for this search
Selection.FormulaR1C1 = "Suite-6"
NEXT5:
End Sub
Thank you for helping me.
Currently i'm use the code below and seems to works fine.
Public LastRow As Long
Sub RunThis()
LastRow = ActiveCell.SpecialCells(xlCellTypeLastCell).Row
Suite6
End Sub
'==============================FIND===Suite6==================
Sub Suite6()
On Error GoTo NEXT0
'============Search KeyWord 1 2
ActiveSheet.Range("A:A").CurrentRegion.AutoFilter Field:=1, Criteria1:= _
"=*S6R*", Operator:=xlOr, Criteria2:="=*Suite6/*"
On Error Resume Next
Range("B2:B" & LastRow).SpecialCells(xlCellTypeVisible).FormulaR1C1 = "Suite-6"
NEXT0:
On Error GoTo NEXT2
ActiveSheet.Range("A:A").CurrentRegion.AutoFilter Field:=1, Criteria1:= _
"=*Suite 6/*", Operator:=xlOr, Criteria2:="=*Suite_6/*"
On Error Resume Next
Range("B2:B" & LastRow).SpecialCells(xlCellTypeVisible).FormulaR1C1 = "Suite-6"
NEXT2:
On Error GoTo NEXT3
ActiveSheet.Range("A:A").CurrentRegion.AutoFilter Field:=1, Criteria1:= _
"=*Suite-6/*", Operator:=xlOr, Criteria2:="=*Suite6.*"
On Error Resume Next
Range("B2:B" & LastRow).SpecialCells(xlCellTypeVisible).FormulaR1C1 = "Suite-6"
NEXT3:
On Error GoTo NEXT4
ActiveSheet.Range("A:A").CurrentRegion.AutoFilter Field:=1, Criteria1:= _
"=*Suite 6.*", Operator:=xlOr, Criteria2:="=*Suite_6.*"
On Error Resume Next
Range("B2:B" & LastRow).SpecialCells(xlCellTypeVisible).FormulaR1C1 = "Suite-6"
NEXT4:
On Error GoTo NEXT5
ActiveSheet.Range("A:A").CurrentRegion.AutoFilter Field:=1, Criteria1:= _
"=*Suite-6.*", Operator:=xlOr, Criteria2:="=*Suite-6/*"
On Error Resume Next
Range("B2:B" & LastRow).SpecialCells(xlCellTypeVisible).FormulaR1C1 = "Suite-6"
NEXT5:
End Sub
Bookmarks