Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default Search for Change in a column.

If there a low impact way of searching a colomn for a change.

i.e. Column 5 has 204 rows of "Text1", then 318 rows of "Text3" then 128
rows of "Text2", then 356 rows of "Text3", etc. At run time, I "know" column
5 and how many total rows I have, but I don't know the actual values I may
find or how many of each I'll have.

Fuctionally, I would like something similar to:

Set rngSearchRange = Range(Cells(1,5),Cells(lngLastRow, 5)
strSearchText = rngSearchRange.Cells(1).Value

Set rngHitCell = rngSearchRange .Find(What:= ^strSearchText)
'First cell that
doesn't match

While Not rngHitCell is Nothing
<Do processing on Section upto HitCell

Set rngSearchRange = Range(rngHitCell,Cells(lngLastRow,5)
strSearchText = rngHitCell.Value
Set rngHitCell = rngSearchRange .Find(What:= ^strSearchText)
Wend

Right now, the fastest way seems to be read the column into a variant to
move it into memory, iterate through the array, and process worksheet based
on index values in the variant. This question is not a matter of finding a
way to do what I want, it's about finding a better way.

TIA, Bob
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Search for Change in a column.

Hi Bob,

I use the following often after the data is placed in 'column 5':

1. Use the advanced data filter to extract all unique values from 'column 5'
to a 'spare' column.
2. Use in column 'spare+1' the somproduct formula to count the number of
ocurrances of the values fixed in 'spare' in column 5. Or with the COUNTIF
function.

I hope you can understand.

Best regards,

Gijs

"INTP56" wrote:

If there a low impact way of searching a colomn for a change.

i.e. Column 5 has 204 rows of "Text1", then 318 rows of "Text3" then 128
rows of "Text2", then 356 rows of "Text3", etc. At run time, I "know" column
5 and how many total rows I have, but I don't know the actual values I may
find or how many of each I'll have.

Fuctionally, I would like something similar to:

Set rngSearchRange = Range(Cells(1,5),Cells(lngLastRow, 5)
strSearchText = rngSearchRange.Cells(1).Value

Set rngHitCell = rngSearchRange .Find(What:= ^strSearchText)
'First cell that
doesn't match

While Not rngHitCell is Nothing
<Do processing on Section upto HitCell

Set rngSearchRange = Range(rngHitCell,Cells(lngLastRow,5)
strSearchText = rngHitCell.Value
Set rngHitCell = rngSearchRange .Find(What:= ^strSearchText)
Wend

Right now, the fastest way seems to be read the column into a variant to
move it into memory, iterate through the array, and process worksheet based
on index values in the variant. This question is not a matter of finding a
way to do what I want, it's about finding a better way.

TIA, Bob

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default Search for Change in a column.

Gijs,

I was hoping for something that didn't involve using a column either. In a
sense, I'm exchanging memory space for Worksheet space.

Another way by adding an extra column is to create a column that increments
if the previous row is the same as the current row, or set to a 1 if not.
Then I can use the .Find command on that column to look for 1's, which is now
a flag that indicates something changed. The advantage of this method over
reading it into a variant is the user can look at the formula and understand
what's happening without having to explain VBA code.

Thanks for your input.

Bob


"Gijs Breedveld" wrote:

Hi Bob,

I use the following often after the data is placed in 'column 5':

1. Use the advanced data filter to extract all unique values from 'column 5'
to a 'spare' column.
2. Use in column 'spare+1' the somproduct formula to count the number of
ocurrances of the values fixed in 'spare' in column 5. Or with the COUNTIF
function.

I hope you can understand.

Best regards,

Gijs

"INTP56" wrote:

If there a low impact way of searching a colomn for a change.

i.e. Column 5 has 204 rows of "Text1", then 318 rows of "Text3" then 128
rows of "Text2", then 356 rows of "Text3", etc. At run time, I "know" column
5 and how many total rows I have, but I don't know the actual values I may
find or how many of each I'll have.

Fuctionally, I would like something similar to:

Set rngSearchRange = Range(Cells(1,5),Cells(lngLastRow, 5)
strSearchText = rngSearchRange.Cells(1).Value

Set rngHitCell = rngSearchRange .Find(What:= ^strSearchText)
'First cell that
doesn't match

While Not rngHitCell is Nothing
<Do processing on Section upto HitCell

Set rngSearchRange = Range(rngHitCell,Cells(lngLastRow,5)
strSearchText = rngHitCell.Value
Set rngHitCell = rngSearchRange .Find(What:= ^strSearchText)
Wend

Right now, the fastest way seems to be read the column into a variant to
move it into memory, iterate through the array, and process worksheet based
on index values in the variant. This question is not a matter of finding a
way to do what I want, it's about finding a better way.

TIA, Bob

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
Search for a column based on the column header and then past data from it to another column in another workbook minkokiss Excel Programming 2 April 5th 07 01:12 AM
Based on a condition in one column, search for a year in another column, and display data from another column in the same row look [email protected] Excel Programming 2 December 30th 06 06:23 PM
Based on a condition in one column, search for a year in another column, and display data from another column in the same row look [email protected] Excel Discussion (Misc queries) 1 December 27th 06 05:47 PM
Loop through column headers to search from column name and get cell range Pie Excel Programming 9 December 29th 05 12:17 AM
URGENT -- search in string for a value in another column, if found, return value from next column samkshah Excel Programming 4 October 3rd 05 04:13 PM


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

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

About Us

"It's about Microsoft Excel"