Excel 2010 VBA Help Copying Ranges of Columns

My code works almost as desired. It checks all sheets for a certain value in Column "F" and then copies its associated row to the active sheet. I can make the code copy the entire row, singular columns "A", or sequential ranges "A:C". I cannot seem to make it copy specific columns like "A" "C" & "F" which is what I need it to do.

Public Sub List()
Dim ws As Worksheet
Dim i As Integer

ActiveSheet.Rows("3:" & ActiveSheet.Rows.Count).Clear
Selection.Clear

For Each ws In Worksheets

    If ws.Name <> ActiveSheet.Name Then

        For i = 1 To ws.Cells(ws.Rows.Count, "A").End(xlUp).Row

            If ws.Cells(i, "F").Value = "Pending" Then

                ws.Cells(i, "A").Columns("A:D").Copy Destination:=ActiveSheet.Range("A" & Rows.Count).End(xlUp).Offset(1, 0)

            End If

        Next

    End If

Next

Answers


As following from comments to Question, correct answer is to use following line:

ws.Range("A" & i & ", C" & i & ", E" & i).Copy Destination:=ActiveSheet.Range("A" & Rows.Count).End(xlUp).Offset(1, 0)

instead

ws.Cells(i, "A").Columns("A:D").Copy Destination:=ActiveSheet.Range("A" & Rows.Count).End(xlUp).Offset(1, 0)

Need Your Help

Send and receive IPv6 link-local multicast UDP datagrams in Python?

python udp posix ipv6 multicast

This following is a straightforward IPv4 UDP broadcast, followed by listening on all interfaces.