Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Selecting data for certain conditions.


I have data arranged in 60 columns with multiple rows of data. How do
you select certain rows based on data criteria in the columns?

For example:

Report the rows with columns 1 - 16 where data in column X is 20,
column Y is < .25, column Z 15.5, etc., etc.


--
Jim15
------------------------------------------------------------------------
Jim15's Profile: http://www.excelforum.com/member.php...o&userid=26300
View this thread: http://www.excelforum.com/showthread...hreadid=400774

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Selecting data for certain conditions.

Look under the data menu at Data=filters. Then use Autofilter or Advanced
filter.

--
Regards,
Tom Ogilvy


"Jim15" wrote in
message ...

I have data arranged in 60 columns with multiple rows of data. How do
you select certain rows based on data criteria in the columns?

For example:

Report the rows with columns 1 - 16 where data in column X is 20,
column Y is < .25, column Z 15.5, etc., etc.


--
Jim15
------------------------------------------------------------------------
Jim15's Profile:

http://www.excelforum.com/member.php...o&userid=26300
View this thread: http://www.excelforum.com/showthread...hreadid=400774



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Selecting data for certain conditions.

If I follow correctly the "60" columns you mentioned is not directly
relevant, only the extent of rows to look in and the individual columns, say
X, Y, Z .

Sub test()
Dim b As Boolean
Dim rRws As Range
Dim rLook As Range
Dim nFirst As Long, nLast As Long
Dim v
Dim vCols

nFirst = 2 ' first row to look in
nLast = 40
vCols = Array("X", "Y", "Z")

For i = nFirst To nLast
b = False
For Each v In vCols
If Cells(i, v).Value 20 Then
b = True
Exit For
End If
If Cells(i, v).Value < 0.25 Then
b = True
Exit For
End If
If Cells(i, v).Value 15.5 Then
b = True
Exit For
End If
Next
If b Then
If rRws Is Nothing Then
Set rRws = Range(Cells(i, 1), Cells(i, 16))
Else
Set rRws = Union(rRws, Range(Cells(i, 1), Cells(i, 16)))
End If
End If
Next

If Not rRws Is Nothing Then
rRws.Select
Else
MsgBox "Nothing matched"
End If

End Sub

Report the rows with columns 1 - 16


I took that to mean select only part rows, between columns 1 - 16

If you have 000's of rows with the potential to create a union of more than
a few hundred discontiguous areas, this will become slow. If that's a
possibility break down into smaller sections, process each separately.

Regards,
Peter T


"Jim15" wrote in
message ...

I have data arranged in 60 columns with multiple rows of data. How do
you select certain rows based on data criteria in the columns?

For example:

Report the rows with columns 1 - 16 where data in column X is 20,
column Y is < .25, column Z 15.5, etc., etc.


--
Jim15
------------------------------------------------------------------------
Jim15's Profile:

http://www.excelforum.com/member.php...o&userid=26300
View this thread: http://www.excelforum.com/showthread...hreadid=400774



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Selecting data for certain conditions.

Or use an advanced filter which should be more efficient or even could be
done without code.

--
Regards,
Tom Ogilvy

"Peter T" <peter_t@discussions wrote in message
...
If I follow correctly the "60" columns you mentioned is not directly
relevant, only the extent of rows to look in and the individual columns,

say
X, Y, Z .

Sub test()
Dim b As Boolean
Dim rRws As Range
Dim rLook As Range
Dim nFirst As Long, nLast As Long
Dim v
Dim vCols

nFirst = 2 ' first row to look in
nLast = 40
vCols = Array("X", "Y", "Z")

For i = nFirst To nLast
b = False
For Each v In vCols
If Cells(i, v).Value 20 Then
b = True
Exit For
End If
If Cells(i, v).Value < 0.25 Then
b = True
Exit For
End If
If Cells(i, v).Value 15.5 Then
b = True
Exit For
End If
Next
If b Then
If rRws Is Nothing Then
Set rRws = Range(Cells(i, 1), Cells(i, 16))
Else
Set rRws = Union(rRws, Range(Cells(i, 1), Cells(i, 16)))
End If
End If
Next

If Not rRws Is Nothing Then
rRws.Select
Else
MsgBox "Nothing matched"
End If

End Sub

Report the rows with columns 1 - 16


I took that to mean select only part rows, between columns 1 - 16

If you have 000's of rows with the potential to create a union of more

than
a few hundred discontiguous areas, this will become slow. If that's a
possibility break down into smaller sections, process each separately.

Regards,
Peter T


"Jim15" wrote in
message ...

I have data arranged in 60 columns with multiple rows of data. How do
you select certain rows based on data criteria in the columns?

For example:

Report the rows with columns 1 - 16 where data in column X is 20,
column Y is < .25, column Z 15.5, etc., etc.


--
Jim15
------------------------------------------------------------------------
Jim15's Profile:

http://www.excelforum.com/member.php...o&userid=26300
View this thread:

http://www.excelforum.com/showthread...hreadid=400774





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Selecting data for certain conditions.

Indeed, that would be probably be a much better approach. Possibly even the
easier autofilter, as you also suggested previously, with a bit of a nudge.

Regards,
Peter T

"Tom Ogilvy" wrote in message
...
Or use an advanced filter which should be more efficient or even could be
done without code.

--
Regards,
Tom Ogilvy

"Peter T" <peter_t@discussions wrote in message
...
If I follow correctly the "60" columns you mentioned is not directly
relevant, only the extent of rows to look in and the individual columns,

say
X, Y, Z .

Sub test()
Dim b As Boolean
Dim rRws As Range
Dim rLook As Range
Dim nFirst As Long, nLast As Long
Dim v
Dim vCols

nFirst = 2 ' first row to look in
nLast = 40
vCols = Array("X", "Y", "Z")

For i = nFirst To nLast
b = False
For Each v In vCols
If Cells(i, v).Value 20 Then
b = True
Exit For
End If
If Cells(i, v).Value < 0.25 Then
b = True
Exit For
End If
If Cells(i, v).Value 15.5 Then
b = True
Exit For
End If
Next
If b Then
If rRws Is Nothing Then
Set rRws = Range(Cells(i, 1), Cells(i, 16))
Else
Set rRws = Union(rRws, Range(Cells(i, 1), Cells(i, 16)))
End If
End If
Next

If Not rRws Is Nothing Then
rRws.Select
Else
MsgBox "Nothing matched"
End If

End Sub

Report the rows with columns 1 - 16


I took that to mean select only part rows, between columns 1 - 16

If you have 000's of rows with the potential to create a union of more

than
a few hundred discontiguous areas, this will become slow. If that's a
possibility break down into smaller sections, process each separately.

Regards,
Peter T


"Jim15" wrote in
message ...

I have data arranged in 60 columns with multiple rows of data. How do
you select certain rows based on data criteria in the columns?

For example:

Report the rows with columns 1 - 16 where data in column X is 20,
column Y is < .25, column Z 15.5, etc., etc.


--
Jim15


------------------------------------------------------------------------
Jim15's Profile:

http://www.excelforum.com/member.php...o&userid=26300
View this thread:

http://www.excelforum.com/showthread...hreadid=400774









Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
data selecting climate Excel Worksheet Functions 2 November 4th 08 05:45 AM
Selecting most recent data within several lines of data wilson@irco Excel Discussion (Misc queries) 0 June 19th 08 07:03 PM
Pivot charts - data disappear after selecting or data are static Patricia Maklari Excel Worksheet Functions 0 July 24th 07 01:36 PM
Selecting data cyc Excel Worksheet Functions 1 August 3rd 06 01:51 PM
selecting data Darron Ross Excel Programming 1 August 28th 03 07:19 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"