+ Reply to Thread
Results 1 to 2 of 2

Macro to select various cells

  1. #1
    Registered User
    Join Date
    09-26-2005
    Posts
    2

    Macro to select various cells

    OK,

    Here is what I am trying to accomplish: I have a large worksheet I am working with and I am working on a macro to select certain cells that meet a specific criteria and copy and paste those cells only into another worksheet. I have the select and paste part down but how to I enable it to assign a condition? For example, I would like the macro to select all the cells that contain 99 in the front of the number of one column and copy those cells into another worksheet. Can someone please point me in the right direction? Thanks in advance.

    -Dave

  2. #2
    Tom Ogilvy
    Guest

    Re: Macro to select various cells

    for each cell in Range("B2:B50")
    if left(cell.Value,2) = "99" then
    if rng is nothing then
    set rng = cell
    else
    set rng = union(rng,cell)
    end if
    end if
    Next
    if not rng is nothing then
    rng.copy Destination:=Worksheets("Sheet3").Range("A1")
    end if

    depending on the arrangement of the cells you select you may be able to do
    it with one copy command as shown, or you may have to loop through your
    "rng" and copy each area individually.

    --
    Regards,
    Tom Ogilvy

    "DSC174" <[email protected]> wrote in
    message news:[email protected]...
    >
    > OK,
    >
    > Here is what I am trying to accomplish: I have a large worksheet I am
    > working with and I am working on a macro to select certain cells that
    > meet a specific criteria and copy and paste those cells only into
    > another worksheet. I have the select and paste part down but how to I
    > enable it to assign a condition? For example, I would like the macro
    > to select all the cells that contain 99 in the front of the number of
    > one column and copy those cells into another worksheet. Can someone
    > please point me in the right direction? Thanks in advance.
    >
    > -Dave
    >
    >
    > --
    > DSC174
    > ------------------------------------------------------------------------
    > DSC174's Profile:

    http://www.excelforum.com/member.php...o&userid=27553
    > View this thread: http://www.excelforum.com/showthread...hreadid=470759
    >




+ 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