ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Selection of several records (https://www.excelbanter.com/excel-programming/346249-selection-several-records.html)

LoveCandle[_15_]

Selection of several records
 

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

--
LoveCandl
-----------------------------------------------------------------------
LoveCandle's Profile: http://www.excelforum.com/member.php...fo&userid=2861
View this thread: http://www.excelforum.com/showthread.php?threadid=48715


Dave Peterson

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

LoveCandle[_16_]

Selection of several records
 

Thank you very much,, That is really what I am looking for

--
LoveCandl
-----------------------------------------------------------------------
LoveCandle's Profile: http://www.excelforum.com/member.php...fo&userid=2861
View this thread: http://www.excelforum.com/showthread.php?threadid=48715



All times are GMT +1. The time now is 06:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com