Copy a by macro special selected nr of rows into another file
jmslab wrote:
Perhaps you can help me out with a (minor?)change.
The macro works now on one selected field and it looks now in column A
if there is the same data in it in the nearby records. When the data in
column A is the same in several records the macro select all this
records for copying.
Is it possible to combine this macro with an option that if you selected
more then one datafield (for example B4:B10) that the macro looks also
to column A but now there is the possiblity that there is not only AAA
filled in, but also in some records BBB. Then the macro has to select
also all the AAA records but also together the BBB records (so.... there
could be more then one unique value in column A).
De rest of the macro keeps the same - copy to another file.
So, you want every row with a selected cell to be part of what's used as the
basis for copying? Using your original example, if rows 6 and 8 are
selected, you want to match both BBB and DDD? If so, it's just a matter of
replacing the "Find the data" section with this:
'Find the data.
For Each cel In Selection.Cells
For L0 = 2 To Cells.SpecialCells(xlCellTypeLastCell).Row
'Case-sensitive.
If Cells(L0, 1).Value = Cells(cel.Row, 1).Value Then
working = working & ",A" & Trim$(Str$(L0))
End If
Next
Next
(The next line should be "If Len(working) Then".)
No options needed. Whether you select a single cell or the entire sheet,
this should do what you want.
--
War is the greatest of teachers, and not all of its lessons are bad.
Their cost is just so terribly high.
|