Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Is there anything in Visual Basic that is similar to SYMBOLIC CONSTANTS as
used in the C Language. For Example, in C: #define AAA sheet4.cells(35,6) Sub SomeSub() AAA = "xyz" end sub The compiler encounters the "#define" directive and thereafter replaces all occurrences of "AAA" with "sheet4.cells(35,6)". So it then ends up compiling the statement: sheet4.cells(35,6) = "xyz" thanks, ken |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hello Ken, No, there isn't. Sincerely, Leith Ross -- Leith Ross ------------------------------------------------------------------------ Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465 View this thread: http://www.excelforum.com/showthread...hreadid=514163 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
No, afraid it doesn't. But this may be enough for you
Dim AAA As Range Sub Main Set AAA = sheet4.cells(35,6) ... SomeSub ... End Sub Sub SomeSub() AAA = "xyz" End Sub -- HTH Bob Phillips (remove nothere from the email address if mailing direct) "Ken Soenen" wrote in message ... Is there anything in Visual Basic that is similar to SYMBOLIC CONSTANTS as used in the C Language. For Example, in C: #define AAA sheet4.cells(35,6) Sub SomeSub() AAA = "xyz" end sub The compiler encounters the "#define" directive and thereafter replaces all occurrences of "AAA" with "sheet4.cells(35,6)". So it then ends up compiling the statement: sheet4.cells(35,6) = "xyz" thanks, ken |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
ken,
Sounds very similar to declaring a "constant". Constants can only be declared as one of the following data types: _ Boolean, Byte, Integer, Long, Currency, Single, Double, Date, String, or Variant. A constant can be declared in a Module or within a Sub routine. The code would look something like... Public Const LONG_AGE As Long = 99 Note however that objects are not one of the data types. So for a range object (cells) you would instead use a variable by... 1. declaring its data type 2. assigning the range to the variable using a "Set" statement. Dim objRange as Excel.Range Set objRange = Worksheets("Sheet4").Cells(35, 6) Then you can use objRange when you assign a value to those excel cells... objRange.Value = "xyz" The Range object has several properties. The Value property is the default property. However, it is good practice to always specify the property that is being used. Regards, Jim Cone San Francisco, USA "Ken Soenen" wrote in message... Is there anything in Visual Basic that is similar to SYMBOLIC CONSTANTS as used in the C Language. For Example, in C: #define AAA sheet4.cells(35,6) Sub SomeSub() AAA = "xyz" end sub The compiler encounters the "#define" directive and thereafter replaces all occurrences of "AAA" with "sheet4.cells(35,6)". So it then ends up compiling the statement: sheet4.cells(35,6) = "xyz" thanks, ken |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Ken,
No, VBA doesn't have what you are looking for. You can, however, use Property Get procedures in your module. E.g., Property Get AAA() As Range Set AAA = Range("A1") End Property Sub BBB() AAA.Value = 123 End Sub -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Ken Soenen" wrote in message ... Is there anything in Visual Basic that is similar to SYMBOLIC CONSTANTS as used in the C Language. For Example, in C: #define AAA sheet4.cells(35,6) Sub SomeSub() AAA = "xyz" end sub The compiler encounters the "#define" directive and thereafter replaces all occurrences of "AAA" with "sheet4.cells(35,6)". So it then ends up compiling the statement: sheet4.cells(35,6) = "xyz" thanks, ken |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks for all your replies. The suggestions for using the SET keyword and
RANGE gives me what I'm looking for. Which is using a "descriptive" name instead of the cell location. thanks, ken "Ken Soenen" wrote in message ... Is there anything in Visual Basic that is similar to SYMBOLIC CONSTANTS as used in the C Language. For Example, in C: #define AAA sheet4.cells(35,6) Sub SomeSub() AAA = "xyz" end sub The compiler encounters the "#define" directive and thereafter replaces all occurrences of "AAA" with "sheet4.cells(35,6)". So it then ends up compiling the statement: sheet4.cells(35,6) = "xyz" thanks, ken |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How can I show radians in symbolic format in excel? like 90 degrees would show (Symbol Pi/2) tia sal2 | Excel Worksheet Functions | |||
Better example I hope how can I show radians in symbolic format in excel? like 90 degrees would show (Symbol Pi/2) tia sal2 | Excel Discussion (Misc queries) | |||
Better example I hope how can I show radians in symbolic format in excel? like 90 degrees would show (Symbol Pi/2) tia sal2 | Excel Worksheet Functions | |||
How can I show radians in symbolic format in excel? like 90 degrees would show (Symbol Pi/2) tia sal2 | Excel Discussion (Misc queries) | |||
How can I show radians in symbolic format in excel? like 90 degrees would show (Symbol Pi/2) tia sal2 | Excel Worksheet Functions |