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?
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
I don't know how End(3) is working for you. The constants, according to Excel's help file are:

xlDown: -4121
xlToLeft: -4159
xlToRight: -4161
xlUp: -4162

I would recommend using the xl*direction* method rather than typing in the numeric constant. It will maintain readability of your code, and make it easier to debug and follow should you (or someone else) have the need to in the future)
 
Upvote 0
I don't know how End(3) is working for you. The constants, according to Excel's help file are:

xlDown: -4121
xlToLeft: -4159
xlToRight: -4161
xlUp: -4162

I would recommend using the xl*direction* method rather than typing in the numeric constant. It will maintain readability of your code, and make it easier to debug and follow should you (or someone else) have the need to in the future)


Thanks for your reply. However, I wanted to know where I saw the (3) replacing (xlUp). I now know that (2) can replace (xlDown). Lacking the ability too find this information is only making more curious. It must be somewhere.
 
Upvote 0
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.
 
Upvote 0
John

You can find all the Excel VBA constants in the Object Browser, which you can access using F2 in the VBE.

They are all listed grouped by the collections they belong to, eg XLDirection is the group for xlDown, xlUp etc.

You can also find them by searching for the objects/methods etc you want to use them with.

I agree though, stick with the 'name'.
 
Upvote 0
I would've said the same, except for recently I've been writing code in Access to create and modify Excel spreadsheets and xlup, xldown etc don't mean anything in the access environment unless you define them yourself (what I did) or reference the Excel executable (didn't see the point for the sake of half a dozen variables, but I may be wrong...)
 
Upvote 0
You can also find them with something quick like this:
Code:
Sub test()
MsgBox xlDown
End Sub
 
Upvote 0
Makes the code more legible, and you can then reuse those anywhere in the code.
 
Upvote 0
John

You can find all the Excel VBA constants in the Object Browser, which you can access using F2 in the VBE.

They are all listed grouped by the collections they belong to, eg XLDirection is the group for xlDown, xlUp etc.

You can also find them by searching for the objects/methods etc you want to use them with.

I agree though, stick with the 'name'.

I'm just trying to learn things I don't know. Thanks for the information Norie. And thanks to all who replied.
 
Upvote 0
Weaver

It's pretty easy to declare the constants in another application.

You could just dedicate a whole module to it and you could add constants as needed.

I suppose you could even copy/import that module between applications.

Oh, and if you use early binding the constants will work.
 
Upvote 0

Forum statistics

Threads
1,223,884
Messages
6,175,173
Members
452,615
Latest member
bogeys2birdies

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