+ Reply to Thread
Results 1 to 4 of 4

Selecting Non-Consecutive Variables

  1. #1
    Registered User
    Join Date
    06-10-2004
    MS-Off Ver
    Office 2003
    Posts
    70

    Selecting Non-Consecutive Variables

    Hello Experts!

    I've written some code that prompts the user to indicate which column two type of data appear in.

    I then want to select those two columns, which may not be next to each other, to copy to another sheet.

    I've tried both versions below but neither work! Can anyone tell me where I'm going wrong?

    Columns(ISBNCol & "," & QtyCol).Select
    Columns(ISBNCol, QtyCol).Select

    Thanks

    Colin

  2. #2
    Bernie Deitrick
    Guest

    Re: Selecting Non-Consecutive Variables

    Colin,

    It depends on what ISBNCol and QtyCol are: numbers, ranges, strings?

    If numbers (3, 5, for example) or strings ("C", "E", for example):

    Union(Columns(ISBNCol), Columns(QtyCol)).Select

    If ranges:

    Union(ISBNCol.EntireColumn, QtyCol.EntireColumn).Select

    HTH,
    Bernie
    MS Excel MVP


    "Colin Vicary" <[email protected]> wrote in message
    news:[email protected]...
    >
    > Hello Experts!
    >
    > I've written some code that prompts the user to indicate which column
    > two type of data appear in.
    >
    > I then want to select those two columns, which may not be next to each
    > other, to copy to another sheet.
    >
    > I've tried both versions below but neither work! Can anyone tell me
    > where I'm going wrong?
    >
    > Columns(ISBNCol & "," & QtyCol).Select
    > Columns(ISBNCol, QtyCol).Select
    >
    > Thanks
    >
    > Colin
    >
    >
    > --
    > Colin Vicary
    > ------------------------------------------------------------------------
    > Colin Vicary's Profile: http://www.excelforum.com/member.php...o&userid=10472
    > View this thread: http://www.excelforum.com/showthread...hreadid=507283
    >




  3. #3
    Dave Peterson
    Guest

    Re: Selecting Non-Consecutive Variables

    Union(Columns(ISBNCol), Columns(QtyCol)).Select

    But you don't usually have to select a range to work with it.


    Colin Vicary wrote:
    >
    > Hello Experts!
    >
    > I've written some code that prompts the user to indicate which column
    > two type of data appear in.
    >
    > I then want to select those two columns, which may not be next to each
    > other, to copy to another sheet.
    >
    > I've tried both versions below but neither work! Can anyone tell me
    > where I'm going wrong?
    >
    > Columns(ISBNCol & "," & QtyCol).Select
    > Columns(ISBNCol, QtyCol).Select
    >
    > Thanks
    >
    > Colin
    >
    > --
    > Colin Vicary
    > ------------------------------------------------------------------------
    > Colin Vicary's Profile: http://www.excelforum.com/member.php...o&userid=10472
    > View this thread: http://www.excelforum.com/showthread...hreadid=507283


    --

    Dave Peterson

  4. #4
    Registered User
    Join Date
    06-10-2004
    MS-Off Ver
    Office 2003
    Posts
    70
    Genius!

    Thank you, worked perfectly.

    Colin

+ Reply to Thread

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