Results 1 to 2 of 2

Issue with Looping Filtered Range of Visible Cells

Threaded View

  1. #1
    Forum Contributor
    Join Date
    06-05-2013
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2016
    Posts
    110

    Issue with Looping Filtered Range of Visible Cells

    Dear all,

    I'm trying to loop through Filtered Range of Visible Cells. Unfortunately, I'm just able to

    I'm looping through names of players ( Players sheet) and mapping their clubs (Player sheet).

    The mapping just doesn't seem to work for 1st row of data (except header) i.e for Player " B "

    PFA for sample data.

    Here's the code logic.
    Sub Club_Mapping()
    
        Sheets("Players").Select
        Range("A1").Select
     
        ' Look for Name column
        Cells.Find(What:="Name", After:=ActiveCell, LookIn:=xlFormulas, _
        LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Activate
        
        ActiveCell.Offset(1, 0).Select
        
        Dim name As String
        Dim club As String
        
        Do Until IsEmpty(ActiveCell)
            
            name = ActiveCell.Value
            club = ActiveCell.Offset(0, 1).Value
            
            
            Sheets("Player").Select
            Range("A1").Select
        
            'Filtering to get the required rows
            Dim plRange As Range
     
            ' Look for Player column
            Set plRange = Cells.Find(What:="Player", After:=ActiveCell, LookIn:=xlFormulas, _
            LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
            MatchCase:=False, SearchFormat:=False)
            
            'Mention your criteria for the Filter
            Selection.AutoFilter
            ActiveSheet.Range("$A$1:$C$1").AutoFilter Field:=plRange.Column, Criteria1:=name
            
            Dim playerRange As Range
            Set playerRange = Range("B2:B" & Range("B65536").End(xlUp).Row).SpecialCells(xlCellTypeVisible)
            
            'Looping Filtered Range
            For Each p In playerRange
            
                p.Select
                
                ActiveCell.Offset(0, 1).Value = club
            
            Next
            
            Sheets("Players").Select
            ActiveCell.Offset(1, 0).Select
            
        Loop
        
        Range("A1").Select
        ActiveWorkbook.Save
        
        MsgBox "Done"
    
    End Sub
    Appreciate your help in correcting me and helping me understand the mistake.

    Thanks,
    Vinod Krishna
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Copy Visible Cells Using Offset.Value in a Filtered Range
    By PreLives in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-17-2014, 01:09 PM
  2. [SOLVED] Excel VBA - Issue in Naming Filtered Range on a Filtered List.
    By Vinod Krishna.C in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-06-2014, 01:17 PM
  3. [SOLVED] Copy visible filtered range
    By Yxx in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-11-2013, 11:06 AM
  4. Looping through a Range,Filter and copy visible cells
    By realniceguy5000 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-31-2011, 02:14 PM
  5. average of visible cells in a filtered range
    By dave roth in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-23-2005, 08:06 AM

Tags for this Thread

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