selecting columns in a macro
Amazing chart utilities from Jon Peltier
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: selecting columns in a macro

  1. #1
    New Member
    Join Date
    Apr 2002
    Posts
    16
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    I want to write a Macro to slect and copy data from a column of data. The data files have variable number of columns, but all have one column with the text heading "36". Is there a way to select theis column based on its heading?
    Thanks.

  2. #2
    MrExcel MVP Jay Petrulis's Avatar
    Join Date
    Mar 2002
    Location
    Chicago, IL USA
    Posts
    2,040
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi,

    Try the following. I don't know where you want to copy to, so this just leaves the "marching ants" around the column that has been copied.

    -------------
    Sub test()
    Dim x As Integer

    With ActiveSheet
    .UsedRange
    For x = 1 To .Cells.SpecialCells(xlCellTypeLastCell).Column
    If Left(Cells(1, x), 2) = "36" Then Columns(x).Copy
    Next x
    End With

    End Sub
    ------------------

    Bye,
    Jay

  3. #3

    Join Date
    Mar 2002
    Posts
    22
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    Or more simply :-

    Sub test()
    ActiveSheet.Rows(1).Find("36").EntireColumn.Copy
    End Sub

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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

 

 
DMCA.com