andrew93
09-26-2006, 03:42 AM
Hi
I have a project where I'm using VB6 and I would like to create a named range in an Excel spreadsheet. I have opened the spreadsheet using DAO and copied data into it and it is working fine and dandy but now I am stuck (I've searched here, Google, VB City, MrExcel etc without luck).
How do I set the name for a selected range using VB? I can see the VBA equivalent code (I'm using VB6 with VBA references & Excel references enabled) but the sheet name, the name I want to use for the named range and the range I want to name are all held in variables.
If I use the macro recorder the equivalent code in VBA looks like this :
'ActiveWorkbook.Names.Add Name:="T_Classification", RefersToR1C1:= _
"=Sheet7!R1C1:R18C3"
but how do I code this if the new name, the sheet name and the range values are held in variables? My range variable values are stored as numbers (e.g. Row 1, Column 1 etc.)
TIA, Andrew
I have a project where I'm using VB6 and I would like to create a named range in an Excel spreadsheet. I have opened the spreadsheet using DAO and copied data into it and it is working fine and dandy but now I am stuck (I've searched here, Google, VB City, MrExcel etc without luck).
How do I set the name for a selected range using VB? I can see the VBA equivalent code (I'm using VB6 with VBA references & Excel references enabled) but the sheet name, the name I want to use for the named range and the range I want to name are all held in variables.
If I use the macro recorder the equivalent code in VBA looks like this :
'ActiveWorkbook.Names.Add Name:="T_Classification", RefersToR1C1:= _
"=Sheet7!R1C1:R18C3"
but how do I code this if the new name, the sheet name and the range values are held in variables? My range variable values are stored as numbers (e.g. Row 1, Column 1 etc.)
TIA, Andrew