+ Reply to Thread
Results 1 to 4 of 4

Macro to copy paste data to other sheet without zero value

Hybrid View

  1. #1
    Registered User
    Join Date
    11-03-2010
    Location
    Jakarta
    MS-Off Ver
    Excel 2007
    Posts
    63

    Macro to copy paste data to other sheet without zero value

    Dear all,

    I would like to copy then paste to another sheet (sheet "Done") with same format without Zero (0) value but include negative (-) value in column G.

    Please help, thank you before.

    Regards
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    09-18-2014
    Location
    Pakistan
    MS-Off Ver
    2013, 2016
    Posts
    283

    Re: Macro to copy paste data to other sheet without zero value

    Make a Command Button on your sheet
    And add this macro
    Sub DataCopy()
    
    For MY_ROWS_1 = 1 To Sheets(1).Range("A65536").End(xlUp).Row
    
            If Sheets("SUMMARY ALL AGENT").Range("G" & MY_ROWS_1).Value > 0 Then
    
                    Sheets("SUMMARY ALL AGENT").Range("A" & MY_ROWS_1 & ":G" & MY_ROWS_1).Copy _
                        Sheets("DONE").Range("A65536").End(xlUp).Offset(1, 0)
    
            End If
    
    Next MY_ROWS_1
    
    End Sub

  3. #3
    Registered User
    Join Date
    11-03-2010
    Location
    Jakarta
    MS-Off Ver
    Excel 2007
    Posts
    63

    Re: Macro to copy paste data to other sheet without zero value

    Dear AmirSoft

    Thank you for your kind help, but when i run the macro it error "Variable not defined" with debug highlight in "MY_ROWS_1"

  4. #4
    Valued Forum Contributor fredlo2010's Avatar
    Join Date
    07-04-2012
    Location
    Miami, United States
    MS-Off Ver
    Excel 365
    Posts
    762

    Re: Macro to copy paste data to other sheet without zero value

    Hello,

    Run the procedure CopyFilteredData

    Option Explicit
    
    Sub CopyFilteredData()
        
        Dim shSource As Worksheet
        Dim shTarget As Worksheet
        Dim rData As Range
        
        Call TurnExtrasOff
        
        Set shSource = Sheets("SUMMARY ALL AGENT")
        Set shTarget = Sheets("DONE")
        Set rData = shSource.Range("A6", shSource.Cells(shSource.Rows.Count, "A").End(xlUp)).Resize(, 7)
        
        With rData
            ' Filter the data.
            .AutoFilter Field:=7, Criteria1:="<>0", Operator:=xlAnd, Criteria2:="<>"
            
            ' Copy the data.
            .SpecialCells(xlCellTypeVisible).Copy Destination:=shTarget.Range("A6")
            
            ' Clear the filter.
            .AutoFilter Field:=7
        End With
        
        
        Call TurnExtrasOn
        
        ' Clean up
        Set rData = Nothing
        Set shSource = Nothing
        Set shTarget = Nothing
        
    End Sub
        
    
    Sub TurnExtrasOff()
        With Application
            .ScreenUpdating = False
            .EnableEvents = False
            .Calculation = xlCalculationManual
        End With
    End Sub
    
    Sub TurnExtrasOn()
        With Application
            .ScreenUpdating = True
            .EnableEvents = True
            .Calculation = xlCalculationAutomatic
        End With
    End Sub
    Thanks

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Macro to copy data from one sheet, paste in another sheet
    By papi-O in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-30-2014, 04:06 AM
  2. Macro to Copy data from one sheet and paste to another sheet based on a condition
    By SaurabhShri1 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-20-2013, 09:30 AM
  3. Copy and paste data in other sheet with macro
    By anuj_sethi1043 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-26-2010, 01:06 PM
  4. Macro to search the sheet name and copy and paste the data from a major sheet
    By salma2009 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-04-2009, 02:11 AM
  5. Macro to Copy/Paste Data from One Sheet to Another
    By smlaff01 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-09-2007, 02:36 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