Richie(UK) said:
A quick translation for those who don't speak NateO :wink:
Code:
Sub NateO()
MsgBox [c65536].End(3).Item(2).Address
'End can be one of 4 directions; Left,Right,Up,Down : So 3=Up
'Item is used to offset from the specified range, uses rows if only one argument
' Row 1 is the row of the range itself so 2 is down 1 row
End Sub
PS. Nate - couldn't get Item to work without actually adding "Item" - is this because End was used first?
This is a good translation! You can't get the following to fire:
<font face=Courier New><SPAN style="color:darkblue">Sub</SPAN> test()
MsgBox [c65536].End(3)(2).Address(0, 0)
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">Sub</SPAN></FONT>
?
2, is shorthand for item, it works similarily to a collection if you will. Ranges can be fun, work as arrays and collections...
3 is not a column reference, c65536 serves as that. 3 is an acceptable, although not the official, constant for xlup. If you go into the object browser and have a look at xlup, you'll notice:
Const xlUp = -4162 (&HFFFFEFBE)
You could use -4162 in place of xlup. In Excel you could simply use xlup, and probably should for transparency.
I in my board and non-board life I end up doing so much interfacing of applications, Lotus Notes, Access, Word, and one coming to board near you (that doesn't work for me!) and I use late-bound code where I can't use xl constants (anything: xl_______). So I got to playing with the end property and found 3 is good to go. Since xlUp is so prevelent and 3 is shorter, I remember 3 works and I use it in Excel, Access, wherever I go...
Perhaps not the best advice, but the method to my madness. :wink: