How to Copy Range of Filtered Data and Paste it to new work sheet in Excel VBA (without Using Clipboard)

baskar

I want to Copy ColumnA and B to New sheet Range A and B (Source Sheet Filter Applied in ColumnH)

This code is Recorded one, When i use this Random Error comes. Because i have 5 submacro and When i call these sub macro its not run correctly. But individual Macro run perfectly.

So i need to Copy without use of Clipboard like this method. Its not use when filter applied condition

Sheets("GROUP1").Range("A:B").Value = Sheets("Sheet3").Range("A:B").Value

Recorded Macro

Sub Copypaste()
'Application.ScreenUpdating = False

    Sheets("GROUP1").Select

    Cells.Select
    Cells.EntireColumn.AutoFit
    Range("A1:H1").Select
    Range("H1").Activate
    Application.CutCopyMode = False
    Selection.AutoFilter
    ActiveSheet.Range("$A:$H").AutoFilter Field:=8, Criteria1:="K-True", Operator:=xlFilterValues
    Columns("A:B").Select
    Application.CutCopyMode = False
    Selection.Copy

       DoEvents
    Sheets("Sheet3").Select
    Range("A1").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False
End Sub
Edu Garcia

What you could do is loop through the source sheet checking by Cell.RowHeight > 0 then setting DestinationCell.Value = SourceCell.Value. Ex.:

Sub Copypaste()
    Dim lRow As Long, lLastRow As Long, LRowCount As Long

    Sheets("GROUP1").Select

    Cells.Select
    Cells.EntireColumn.AutoFit
    Range("A1:H1").Select
    Range("H1").Activate
    Application.CutCopyMode = False
    Selection.AutoFilter
    ActiveSheet.Range("$A:$H").AutoFilter Field:=8, Criteria1:="K-True", Operator:=xlFilterValues        
    lRowCount = 1
    lLastRow = ActiveSheet.Cells.SpeciallCells(xlCellTypeLastCell).Row

    For lRow = 1 to lLastRow

        If ActiveSheet.Range(lRow).RowHeight > 0 Then
            Sheets("Sheet3").Range("A" & lRowCount & ":B" & lRowCount).Value = ActiveSheet.Range("A" & lRowCount & ":B" & lRowCount).Value
            lRowCount = lRowCount + 1
        End If

    Next

End Sub

P.S.: If you have any issues, please let me know.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Copy filtered data to another sheet using VBA

Excel vba find text in sheet, copy range, paste to other sheet

Copy filtered data from database/excel connection without clipboard

How to copy the values in a range from one sheet to and paste it another sheet on a predefied order using VBA?

VBA - Copy Range and Paste to new sheet, shifting Entire Rows down?

Copy and paste multiple ranges without using the clipboard using VBA

How to copy dynamic range in Excel Sheet using vba

VBA to copy data from one sheet and paste against a range and repeat using LOOP or any other method

Copy and Paste dynamic ranges to new sheet in Excel with VBA

Excel VBA copy data in a range for every 100000 rows and paste to a different sheet until all the data has been copied in the range

How to copy/paste formula in filtered/visible cells via VBA in Excel

How to copy a range and paste diagonally using vba

How do I copy and paste formatting of excel tab to other tabs except a selected sheet using excel VBA

copy paste Range in VBA Excel

VBA Copy range values and paste in another sheet

Excel: How to use Copy Paste command to selected sheet area (VBA)

How to use clipboard to copy data from Excel Sheet to DataTable?

Excel VBA - Copy range from one sheet paste to all sheets after certain sheet in workbook

How to copy range of cells using inputbox and paste to newly created sheet

How to copy or insert multiple range data in InnerText using Excel VBA

how to paste entire column in excel vba without selecting the sheet

VBA - copy filtered range without select

How to copy from a particular cell and paste it in a another range using excel vba

Excel vba - How to copy/paste when range varies

Copy and paste data in a new sheet after clearing the filter in another sheet in VBA

Copy paste using VBA in excel

Using VBA to search data in Excel for a specific word, copy that row and 2 rows above and below into a new sheet

VBA How to copy range data without headers

How can I copy and excel sheet to a new workbook using the print range as the source