Consulting

Results 1 to 2 of 2

Thread: Sleeper: Select uneven columns

  1. #1
    VBAX Mentor
    Joined
    Jun 2005
    Posts
    374
    Location

    Sleeper: Select uneven columns

    hello
    I took advantage of johnske macro(superb as always)
    I got a data from a closed workbook.
    the sheet i got has no formulas only constants of i have to plant the formula again.
    my question- how do i select only the "uneven" columns namely column A,C,E,G etc up to column 30 which is column bj.
    thanks
    moshe

  2. #2
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    Try this macro.

    Option Explicit
     
    Sub SelectColumns()
    Dim i               As Long
    Dim Rng             As Range
    For i = 1 To 30 Step 2
            If Rng Is Nothing Then
                Set Rng = Cells(1, i)
            Else
                Set Rng = Union(Rng, Cells(1, i))
            End If
        Next i
        Rng.EntireColumn.Select
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •