End(3) for end(xlup)

John Davis

Well-known Member
Joined
Sep 11, 2007
Messages
3,457
Hello All:

I read somewhere on the board where there were numbers which can be used to replace XLUP, XLDOWN, XLTOLEFT ect. I use the End(3). However, I'd like to know where to find the other numbers. When I search the board for same, I keep getting no matches found. Can someone enlighten me on where I can find this information?
 
2 is not the same as xlDown, it's xlRight. 4 would be xlDown. You're still much better off using the enumeration though unless you are trying to make your code hard to read.

Thanks for the reply. OK how do you know that 4 is xlDown? Where do I find that information at? I still haven't found it (ie. (1), (2), (3), (4).
 
Upvote 0

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Trial and error, because it shouldn't work. xlDown is -4121 as all the various methods mentioned will show you.
 
Upvote 0
All the options give me a result of "-4121".
Not on my computer:

? xlUp
-4162
? xlToRight
-4161
? xlToLeft
-4159

Where do I find a result of "4" or does it exist anywhere? <!-- / message -->
It's not a member of the xlDirection enumeration.
 
Upvote 0
My best guess would be that the programmer(s) concerned with writing the End method allowed for 1,2,3,4 as shortcuts for left, right, up, down as well as the actual enum values. They are not documented anywhere that I've ever seen , though I have seen End(3) used a number of times.
 
Upvote 0
Not on my computer:

? xlUp
-4162
? xlToRight
-4161
? xlToLeft
-4159


It's not a member of the xlDirection enumeration.

Thanks. I give up. I guess always use End(xlUp). But I know End(3) works. It has been tested, and I know I got the information from reading on the board. I can't remember where. And now I don't know why it works?
 
Upvote 0
He's right. 3 does work, but it is undocumented.

But, I would get go with the named constants for readability, or the documented values so you or other people will understand what the code does later. Just because other values work, doesn't necessarily mean you should use them.
 
Upvote 0
He's right. 3 does work, but it is undocumented.

But, I would get go with the named constants for readability, or the documented values so you or other people will understand what the code does later. Just because other values work, doesn't necessarily mean you should use them.


BTW, to save my sanity I found the others from searching other Forums:

xlToLeft = 1
xlToRight = 2
xlUp = 3
xlDown = 4

Still nothing indicates where these constants were derived. Just was curious?? Guess I'll find the answer one of these days.
 
Upvote 0
Seriously? Do you not read your replies?
 
Upvote 0

Forum statistics

Threads
1,223,876
Messages
6,175,129
Members
452,614
Latest member
MRSWIN2709

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top