Results 1 to 9 of 9

Filtering column A then write text in visible cell B

Threaded View

  1. #1
    Registered User
    Join Date
    04-23-2015
    Location
    Bangkok
    MS-Off Ver
    2010
    Posts
    5

    Filtering column A then write text in visible cell B

    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
    Last edited by noppornph; 05-31-2015 at 09:05 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. VBA for filtering a column then filling down a text for visible cells in another column
    By rajkumarmp in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-18-2013, 04:00 PM
  2. Table Object after filtering - Count visible rows & First visible row
    By limalf in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-13-2013, 07:29 PM
  3. Trying to write amacro to compare text in column A to garbage text in column B
    By Big Dawg Dad in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-19-2013, 03:31 PM
  4. find duplicates for visible cells after filtering for a column
    By sravan.rathnam in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-12-2012, 06:41 AM
  5. Replies: 2
    Last Post: 12-30-2011, 06:22 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1