• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Creating Macro - Issue with copy in a filtered view

k3vsmith

Member
I have an export from a program to an excel worksheet that has several columns (A - P). I have them filtered on column C. This adjusts the view down from 255 records down to 24. Now I need vba code that will copy the contents of column F to column E (for this filtered view only). Do I need to create a range for this view or how do I go about that?
The # of records could vary per export but the columns will always remain the same.
Let me know if you need more information. Thanks in advance.
 
For example, Im filtered on column C. This shows me everything I want to see. Now I want to copy the contents of column F44 to E44, the next row shown in view is copying F47 to E47. Etc.

__________________________________________________________________
Mod edit : post moved to appropriate forum !
 
Something like this (assuming you have already applied your filter).

Code:
Sub CopyVisible()
Dim ws As Worksheet
Dim cRange As Range
Dim lRow As Integer

Set ws = ThisWorkbook.Sheets("Sheet1")
lRow = ws.Range("C" & Rows.Count).End(xlUp).Row

Set cRange = ws.Range("F2:F" & lRow)

For Each cell In cRange.SpecialCells(xlCellTypeVisible)
    cell.Copy cell.Offset(0, -1)
Next cell

End Sub
 
Back
Top