Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

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
 
Old April 8th, 2005, 05:53 AM
Registered User
 
Join Date: Mar 2005
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Map string to cell property


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.


Cheers

Sunil
 
Old April 8th, 2005, 11:58 AM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

I was thinking that the thing to do might be
Code:
    Dim prpProperty As Property
    Set prpProperty = Selection.NumberFormat
    but it appears that there is no Property variable type...

In the bigger picture, what is it that you are trying to do?
 
Old April 9th, 2005, 01:38 AM
Registered User
 
Join Date: Mar 2005
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Brian,

     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.




Cheers

Sunil
 
Old April 17th, 2005, 05:54 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 168
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Sunil

This might be one solution

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

End Sub


-vemaju






Similar Threads
Thread Thread Starter Forum Replies Last Post
Heat Map over Google Map ajit Javascript 0 March 7th, 2008 09:01 AM
Specify the connection string property at runtime Lawrence C. Zauberis BOOK: Professional SQL Server 2005 Integration Services ISBN: 0-7645-8435-9 1 July 7th, 2006 09:40 AM
Conversion of a String tag attribute value to Map monregistre Pro JSP 0 May 15th, 2006 07:53 AM
Lose cell Text when editing cell in VSFlexGrid 6 bobcratchet VB How-To 0 July 30th, 2004 09:32 AM
Property/Method access using string values jaucourt VB.NET 2002/2003 Basics 1 February 10th, 2004 01:05 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.