Thursday 26 March 2015

VBA Extract data from Master sheet to Extraction sheet based on color

Sub Button1_Click()

  ActiveWorkbook.Sheets("Extraction").UsedRange.Offset(1).ClearContents
  ActiveWorkbook.Sheets("Extraction").UsedRange.Offset(1).ClearFormats
    
Dim bottomL2 As Integer
    Dim x2 As Integer
    bottomL2 = Sheets("Master Sheet").Range("A" & Rows.Count).End(xlUp).Row: x2 = 1
    
    Dim c2 As Range
    For Each c2 In Sheets("Master Sheet").Range("A1:A" & bottomL2)
    On Error Resume Next
        If c2.Interior.ColorIndex = 3 Then
         x2 = x2 + 1
            c2.EntireRow.Copy Worksheets("Extraction").Range("A" & x2)
                      
        End If
    Next c2
    End Sub

  

No comments:

Post a Comment