We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,866 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Defining Constants

I'm having some trouble defining constants correctly.

I know the format should be this:

Const CONSTANT_NAME [As ConstantType] = value

But I'm a little unclear of how to word it. So here is the Line I need to change into a Constant. Normally I would have a BAS file do this but I can't find one (Refer to other post).

Code:

With oXLSheet.Range("A1:A10")
        .Font.ColorIndex = 50
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlCenter
End With

That's the entire section that I'm dealing with. I don't think all of it needs to be constants, but maybe it does? I'm not sure. All I know is that the tutorial helping me with creating automation suggested that I turn my Code into Late-Bound to help with compatibility issues a User might have in regards to opening Excel. As a result, I have had to drop the Excel Reference that I was using therefore, having to define my own constants. As stated previous, here and in the other Thread, I wanted to make it easier by Inserting a BAS File into a Module as suggested and provided by the Tutorial I'm using but there were x64 bit compatibility issues with that so I couldn't. If anyone could help me turn the "xlCenter" part into a Constant it would be greatly appreciated. I am very new at this and still learning so I thank you for your patience.

Thank you for taking the time to read this

2
Contributors
1
Reply
4 Days
Discussion Span
11 Months Ago
Last Updated
2
Views
johndmingione
Newbie Poster
2 posts since May 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

Might be a bit late, try this...

''Private if it is used within your current form or public if called from other forms or sheets...

''It also seems that it will be of a type integer(number) ...

Private Const xlCenter As Long = 1 ''Your value here.

''If it is a strin...

Private Const xlCenter As String = "My Value Here"
AndreRet
Industrious Poster
4,706 posts since Jan 2008
Reputation Points: 391
Solved Threads: 481
Skill Endorsements: 20

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.2855 seconds using 2.64MB