PDA

View Full Version : Distinguish the xlup and xldown



Ann_BBO
07-27-2007, 07:46 PM
Basically, i am not sure that the actual operation between xlup and xldown.
Dim Source As Range
Dim Rng As Range
Dim c As Range

Set c =Source.Range("A3")
If Rng Is Nothing Then Set Rng = c.Offset(1)
Set Rng = Union(Rng, Range(c.Offset(1), c.Offset(1).End(xlDown)))
Set c = c.Offset(1).End(xlDown).Offset(1)

To my know, if c=A3, then Rng=A4. Therefore,
Range(c.Offset(1), c.Offset(1).End(xlDown)) =The rectangle area from A4 to H30 where A4:H30 has the value or until ,say, Row 31 is space area and "I" column is space.
Is it correct or not. I am confused that between xlup and xldown.

Moreover, "Union" is it the array to store the same type data.
Thanks

malik641
07-27-2007, 09:16 PM
Between xlUp and xlDown, you should look into the .End() property (this goes for xlToLeft and xlToRight as well). Check that out here (http://msdn2.microsoft.com/en-us/library/bb221181.aspx).

Attached is a workbook that I hope will help you understand the xlDirection enumeration (xlUp, xlDown, xlToLeft, xlToRight). Play with all the buttons and notice how each direction reacts to gaps in ranges, when it's inside an area of range values, when it's outside of range values, etc.

Bob Phillips
07-28-2007, 02:05 AM
Union logically 'joins' two arrays, storing the joined ranege in a range variable that you can then process.

Ann_BBO
07-29-2007, 06:45 PM
Thanks All