Selection of several records

  • Thread starter Thread starter LoveCandle
  • Start date Start date
L

LoveCandle

Hi everybody,

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

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

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


Code
-------------------
Sub Select_Range()
[A7:J7].Select
Range(Selection, Selection.End(xlDown)).Select
End Su
-------------------


I hope that my question is clear for all,

Thank you sooooooo mcuh
 
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
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,
 
Back
Top