You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
To set the property of cell or range we use the followint code
Range("A3").Select
Selection.NumberFormat = "0.00"
Selection.HorizontalAlignment = xlLeft
etc.
Now in my project there is a requirement to map the string to property name.
Say for example
I have a code:-
Dim strProperty As String
strProperty = "NumberFormat"
Now My Question is,is it possible to map strProperty to actual property which this string is holding.
In my project I am comparing various properties like alignment, number format etc between to excel files. Now user can remove certain properties comparison and can add new one at run time. For this I can provide INI. But the question is, is this a feasible solution.
Can I map property name provided by user in INI file to actual property.
Sub Properties()
Dim AcCell As Range
Dim Property As String
Set AcCell = ActiveCell
Property = AcCell.NumberFormat
Debug.Print Property
Property = AcCell.HorizontalAlignment
Debug.Print Property