Copying a block of data

  • Thread starter Thread starter Rick
  • Start date Start date
R

Rick

Hi,
How do I write a macro to select a variable cell range so
that I can copy the block of data elsewhere.
e.g. My data range is A3:A18
Sometimes I have data in cells A3:A6 or A3:A10 etc. It
varies.

I only wish to select the block that contains data,
eleiminating the blank cells. End down takes me to the row
A18, regardless whether or not some of the cells have data
in them.

Could anyone assist please,
Thanks
 
If you are always starting on A3 and the data is all continuous (no
blank cells between values), then this should work for you. I used
the macro recorder to get it.

Range("A3").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy

Random
 
When you say blank, do you mean empty or is there a formula in there
returning an empty string. If the cell is truly empty, I don't
understand why it wouldn't work. Just for kicks, try selecting and
deleting the first "blank" cell below your filled cells and then run
the macro again. If that works, it should be able to point one of the
more experienced programmers here in the right direction.



Random
 
Hi Random,
You are right. Even though the cells were blank they were
derived from a sorting of data. When I clear them and run
your code presto! So I'll incorporate Dave's suggestion
and yours and my problem is solved.
Thanks again.
 
Hi Dave,
The blank cells were derived from a sorting of data. When
I clear them, all is ok. I'll use your code and Dave's to
solve my problem. Tricky eh!
Thanks for your help,
Cheers,
Rick
 
Back
Top