+ Reply to Thread
Results 1 to 2 of 2

Replicating CTRL-click multiple row selection

  1. #1
    normschaef
    Guest

    Replicating CTRL-click multiple row selection

    Hi all:

    I'm working on a project where I'd like to programmatically select a row
    which meet certain criteria, examine the next row and select or skip
    depending on if it meets the conditions, then finally paste all the rows into
    a new worksheet

    I think my psuedocode would look something like.

    If cell "Quantity" is > than 1 then select the Item, Make, Model and
    Quantity cells, if "Quantity" equals 0 then skip the row and check the next
    row.
    When a blank row is reached then copy all the selected rows
    Make a new worksheet and paste the selected range into the new worksheet.

    Am I on the right track or would I need to select a row at a time, paste it
    to the new sheet, then go look at the next row.

    Thanks for any help and guidance.
    Norm



  2. #2
    Jim Thomlinson
    Guest

    RE: Replicating CTRL-click multiple row selection

    Here is some code similar to what you want. It copies and pastes from one
    sheet to a new sheet based on cell values... You can do it by making one big
    "selection" using the union method but in the grander scheme of things I am
    to sure that it helps you much in this case. This copies the entire row but
    it could be modified to grab just a few selected cells.

    Public Sub CopyRows()
    Dim wksFrom As Worksheet
    Dim wksTo As Worksheet
    Dim rngFrom As Range
    Dim rngTo As Range

    Set wksFrom = ActiveSheet
    Set wksTo = Worksheets.Add
    Set rngFrom = wksFrom.Range("A3")
    Set rngTo = wksTo.Range("A1")

    Do While rngFrom.Value <> Empty
    If rngFrom.Value > 1 Then
    rngFrom.EntireRow.Copy rngTo
    Set rngTo = rngTo.Offset(1, 0)
    End If
    Set rngFrom = rngFrom.Offset(1, 0)
    Loop

    End Sub

    HTH

    "normschaef" wrote:

    > Hi all:
    >
    > I'm working on a project where I'd like to programmatically select a row
    > which meet certain criteria, examine the next row and select or skip
    > depending on if it meets the conditions, then finally paste all the rows into
    > a new worksheet
    >
    > I think my psuedocode would look something like.
    >
    > If cell "Quantity" is > than 1 then select the Item, Make, Model and
    > Quantity cells, if "Quantity" equals 0 then skip the row and check the next
    > row.
    > When a blank row is reached then copy all the selected rows
    > Make a new worksheet and paste the selected range into the new worksheet.
    >
    > Am I on the right track or would I need to select a row at a time, paste it
    > to the new sheet, then go look at the next row.
    >
    > Thanks for any help and guidance.
    > Norm
    >
    >


+ 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