+ Reply to Thread
Results 1 to 3 of 3

Selection of several records

  1. #1
    Forum Contributor
    Join Date
    11-07-2005
    Posts
    280

    Selection of several records

    Hi everybody,

    I have this code which works on selecting the filled records starting from the seventh row >>

    It is working properly, but the problem with it is that it selects all filled records even those which have zero value.

    So, I would like you please to edit it to select records that have value greater than zero only.

    Please Login or Register  to view this content.
    I hope that my question is clear for all,

    Thank you sooooooo mcuh,

  2. #2
    Dave Peterson
    Guest

    Re: Selection of several records

    The value is in column A???

    Then maybe something like this will give you an idea:

    Option Explicit
    Sub testme()

    Dim myRng As Range
    Dim iRow As Long
    Dim FirstRow As Long
    Dim LastRow As Long

    With ActiveSheet
    FirstRow = 7
    LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

    For iRow = FirstRow To LastRow
    If .Cells(iRow, "A").Value > 0 Then
    If myRng Is Nothing Then
    Set myRng = .Cells(iRow, "A")
    Else
    Set myRng = Union(.Cells(iRow, "A"), myRng)
    End If
    End If
    Next iRow

    If myRng Is Nothing Then
    MsgBox "Nothing to select!"
    Else
    '.select
    Intersect(myRng.EntireRow, .Range("a:j")).Select
    End If
    End With

    End Sub

    LoveCandle wrote:
    >
    > Hi everybody,
    >
    > I have this code which works on selecting the filled records starting
    > from the seventh row >>
    >
    > It is working properly, but the problem with it is that it selects all
    > filled records even those which have zero value.
    >
    > So, I would like you please to edit it to select records that have
    > value greater than zero only.
    >
    > Code:
    > --------------------
    > Sub Select_Range()
    > [A7:J7].Select
    > Range(Selection, Selection.End(xlDown)).Select
    > End Sub
    > --------------------
    >
    > I hope that my question is clear for all,
    >
    > Thank you sooooooo mcuh,
    >
    > --
    > LoveCandle
    > ------------------------------------------------------------------------
    > LoveCandle's Profile: http://www.excelforum.com/member.php...o&userid=28612
    > View this thread: http://www.excelforum.com/showthread...hreadid=487151


    --

    Dave Peterson

  3. #3
    Forum Contributor
    Join Date
    11-07-2005
    Posts
    280
    Thank you very much,, That is really what I am looking for.

+ 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