Results 1 to 24 of 24

Add two more columns, modifying an existing VBA code help.

Threaded View

  1. #1
    Forum Contributor Anka's Avatar
    Join Date
    08-25-2012
    Location
    Lisbon
    MS-Off Ver
    Excel 2016
    Posts
    174

    Add two more columns, modifying an existing VBA code help.

    Hi all.

    I want some help, to modify this VBA code. I want to copy additional columns Z and AA, the even numbered rows, starting with Z8.
    Thank you in advance.

    Sub test()
        Dim ws As Worksheet, i As Long, x As Range
        Application.ScreenUpdating = False
        With Sheets("CONTROL")
        .Select
            For Each ws In Worksheets(Array(2, 3, 4, 5, 6, 7))
                If ws.Name <> Me.Name Then
                    With ws.Range("b9").CurrentRegion
                        For i = 1 To .Rows.Count Step 2
                            If x Is Nothing Then
                                Set x = .Rows(i).EntireRow.Range("b1,g1:h1")
                            Else
                                Set x = Union(x, .Rows(i).EntireRow.Range("b1,g1:h1"))
                            End If
                        Next
                    End With
                    If Not x Is Nothing Then
                        .Range("b" & Rows.Count).End(xlUp)(2).Select
                        x.Copy
                        Me.Paste link:=True
                    End If
                    Set x = Nothing
                End If
            Next
            .[b3].Select
        End With
        With Application
            .CutCopyMode = False
            .ScreenUpdating = True
        End With
    End Sub
    Last edited by Anka; 02-07-2013 at 04:22 PM.
    Many thanks to all who have helped me.

Thread Information

Users Browsing this Thread

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

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