ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Dynamic property names (https://www.excelbanter.com/excel-programming/413512-dynamic-property-names.html)

Tone[_4_]

Dynamic property names
 
Hi all

In VBA/Excel is there any way I can dynamically refer to property
names. By this I mean that I want to pass a property name as a
parameter e,g,

sub aSub (aCell as Range, aVal as Variant, prop as ???)

....
aCell.prop = aVal ' or some such

....
end sub

so the input parameter "prop" could be "value" or "formula" or
whatever.

Many thanks

Tone

Tone[_4_]

Dynamic property names
 
On 3 Jul, 14:39, Tone wrote:
Hi all

In VBA/Excel is there any way I can dynamically refer to property
names. *By this I mean that I want to pass a property name as a
parameter e,g,

sub aSub (aCell as Range, aVal as Variant, prop as ???)

...
* *aCell.prop = aVal *' or some such

...
end sub

so the input parameter "prop" could be "value" or "formula" or
whatever.

Many thanks

Tone


Answered my own question! - use the function "CallByName"

T


All times are GMT +1. The time now is 04:56 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com