View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
David McRitchie David McRitchie is offline
external usenet poster
 
Posts: 903
Default Get a range of cells from a selection of cells

Unless you are not stating everything, it is not necessary
to know how many rows or columns are in the selection
simply paste to a single cell range.
---
HTH,
David McRitchie, Microsoft MVP - Excel
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"danhattan" wrote in message ...
I currently have some code that searches a range for a specific value in one
column. When it finds that value the entire row is selected and added to
range of rows using the Union method. When the search is over, the rows are
deleted.

I want to adapt the code to find the rows as it does, but then select the
same range of columns within each row so that I can copy and paste them to
another sheet. However, I can't paste rows into the cell I want to because
the selections don't match.

My dilemma is that I know how to capture the number of rows selected from
the code, but don't know how to select the same number of rows on the paste
sheet, starting at a specified row.

Alternately, if I could select just the range of columns within the selected
rows in the first place, that would help too. I looked at various angles, and
finally tried this: rngFoundAll.Columns.Select = "B:F". Unlike previous
attempts with Columns property syntax, it at least compiled, but generated
Error 424 (object required) after running the code above it.

If someone could help with this, as always, much appreciated. I think the
second approach would be more elegant, but either one would accomplish what
I'm looking for. Thanks again.

Dan