R
Ray
I need to write a macro that will search through several groups of cells in
the same column, depending on the values in those cells and return several
cell values, in the same rows as the cells in the search column, to another
sheet in the same workbook.
Example:
Column K (string data type ) is the column that must be searched for a
certain string value.
Column C will contain numbers, like range C1:C9 all contain a value of 1
(the range could be smaller or larger), Range C10:C16 all contain a value of
2 (again the range could be smaller or larger), etc.etc..
Columns A (text), B (date), F(integer), and O(decimal) are the cell values
that need to be sent to the other sheet.
So, the macro would start searching through Column K (K1:K10000 for example)
while Column C is the same value. It is searching for a string value that is
specified in the macro ( I will be copying this macro several times, each
one having a different string value for the search). When it encounters the
search value in Column K it then does a copy of the Cells A,B,F, and O from
the same row and inserts them in the other sheet (inserts a new row at row
10 and pastes the cell values in cells A10,B10,C10, and D10) then goes back
and continues searching Column K until the value in Column C changes. At
that point it will go to the other sheet and insert a blank row, then go
back and start searching Column K again at the row where the Column C value
changed, copying and inserting the values in the other sheet until the
Column C value changes again, insert a blank row in the other sheet, return
and continue searching until the end of the Column K range (K10000)
This is similar to a query in a database where the query looks for a value
and returns the cell values specified for all the rows where the value is
present.
the same column, depending on the values in those cells and return several
cell values, in the same rows as the cells in the search column, to another
sheet in the same workbook.
Example:
Column K (string data type ) is the column that must be searched for a
certain string value.
Column C will contain numbers, like range C1:C9 all contain a value of 1
(the range could be smaller or larger), Range C10:C16 all contain a value of
2 (again the range could be smaller or larger), etc.etc..
Columns A (text), B (date), F(integer), and O(decimal) are the cell values
that need to be sent to the other sheet.
So, the macro would start searching through Column K (K1:K10000 for example)
while Column C is the same value. It is searching for a string value that is
specified in the macro ( I will be copying this macro several times, each
one having a different string value for the search). When it encounters the
search value in Column K it then does a copy of the Cells A,B,F, and O from
the same row and inserts them in the other sheet (inserts a new row at row
10 and pastes the cell values in cells A10,B10,C10, and D10) then goes back
and continues searching Column K until the value in Column C changes. At
that point it will go to the other sheet and insert a blank row, then go
back and start searching Column K again at the row where the Column C value
changed, copying and inserting the values in the other sheet until the
Column C value changes again, insert a blank row in the other sheet, return
and continue searching until the end of the Column K range (K10000)
This is similar to a query in a database where the query looks for a value
and returns the cell values specified for all the rows where the value is
present.