• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 700
  • Last Modified:

sort excel table and copy visible cells invba

Hi experts
I'm trying to sort an excel table in vba , and then copy the visible cells only to a different table on a different sheet any ideas how I can do this in vba ?

cheers
0
Thrawn3000
Asked:
Thrawn3000
  • 2
  • 2
1 Solution
 
StephenJRCommented:
Can you post a workbook?
0
 
Thrawn3000Author Commented:
Yes sure
I want to filter the table in vba for all AAMI values under the brand field and then a specific date as an example and copy these visible cells to a different table. TestFile.xlsx
0
 
StephenJRCommented:
Like this? Not sure what you meant by sorting, did you just mean filtering?
Sub x()

Dim rData As Range

Application.ScreenUpdating = False

With Sheets("Sheet1")
    .AutoFilterMode = False
    .Range("A1").AutoFilter Field:=1, Criteria1:=DateSerial(2010, 7, 31)
    With .AutoFilter.Range
        On Error Resume Next
        Set rData = .Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlCellTypeVisible)
        On Error GoTo 0
        If Not rData Is Nothing Then
            rData.Copy Sheets("Sheet2").Range("A1")
        End If
    End With
    .AutoFilterMode = False
End With

Application.ScreenUpdating = True

End Sub

Open in new window

0
 
Thrawn3000Author Commented:
Awesom, works perfectly
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now