+ Reply to Thread
Results 1 to 2 of 2

Macro Button to copy data from one worksheet to second worksheet with criteria

Hybrid View

  1. #1
    Registered User
    Join Date
    03-05-2013
    Location
    San Antonio, TX
    MS-Off Ver
    Excel 2003
    Posts
    1

    Macro Button to copy data from one worksheet to second worksheet with criteria

    Hello,

    I'm new to this forum and am hoping someone can help me with this one. I have been trying to create a macro that will copy a whole row if the value in E1 on "Output" is equal to the value in column C. I have created an example xlsx file as an example. The number of rows range often. Any help would be appreciated!!
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Macro Button to copy data from one worksheet to second worksheet with criteria

    Sub CombineAllSheets()
    
     Dim ms As Worksheet, LR As Long, i As Long
     
        Application.ScreenUpdating = 0
        Application.DisplayAlerts = 0
        
        On Error Resume Next
        
      Set ms = Sheets("Output")
      
        With Sheets("Data")
        
            LR = .Cells.Find("*", , , , xlByRows, xlPrevious).Row
                
            For i = 2 To LR
               
                 If ms.Range("E1") = .Range("C" & i) Then
                
                   .Rows(i).Copy ms.Range("A" & Rows.Count).End(xlUp).Offset(1)
                
                 End If
            Next i
                 
        End With
          
          Application.CutCopyMode = 0
         
         Application.ScreenUpdating = 1
        
         Application.DisplayAlerts = 1
         Set ms = Nothing
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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