Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default RE Define Named Range.

I need to programmatically redefine a named range (normally created On the
Insert menu, point to Name, and then click Define. Type the name e.g.
MyTable, select the range and then click OK.) in an excel file.
I need to change the range from e.g. A1:D18 to A1:D1.

How can this be done in C#? If you don't know C#, VB is ok too.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default RE Define Named Range.

I usually just do something like this in VBA

ActiveWorkbook.Names.Add "SampleName", "=$A$1:$D$1"


if SampleName doesn't exist yet, it creates it. If it already exists, then
it gets overwritten with the new reference.


--
Hope that helps.

Vergel Adriano


"DeveloperSQL" wrote:

I need to programmatically redefine a named range (normally created On the
Insert menu, point to Name, and then click Define. Type the name e.g.
MyTable, select the range and then click OK.) in an excel file.
I need to change the range from e.g. A1:D18 to A1:D1.

How can this be done in C#? If you don't know C#, VB is ok too.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default RE Define Named Range.

I don't seem to see any Names property of Excel._Workbook.

"Vergel Adriano" wrote:

I usually just do something like this in VBA

ActiveWorkbook.Names.Add "SampleName", "=$A$1:$D$1"


if SampleName doesn't exist yet, it creates it. If it already exists, then
it gets overwritten with the new reference.


--
Hope that helps.

Vergel Adriano


"DeveloperSQL" wrote:

I need to programmatically redefine a named range (normally created On the
Insert menu, point to Name, and then click Define. Type the name e.g.
MyTable, select the range and then click OK.) in an excel file.
I need to change the range from e.g. A1:D18 to A1:D1.

How can this be done in C#? If you don't know C#, VB is ok too.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default RE Define Named Range.

Sorry, I'm a VB guy.

FWIW, this worked with VB.NET. I have the Excel 11 Object Library.


Imports Microsoft.Office.Interop

Module Module1
Sub Main()
Dim xlapp As New Excel.Application
Dim xlwb As Excel.Workbook
xlapp.Visible = True
xlwb = xlapp.Workbooks.Add
xlwb.Names.Add("SampleName", "=$A$1:$D$1")
End Sub
End Module

--
Hope that helps.

Vergel Adriano


"DeveloperSQL" wrote:

I don't seem to see any Names property of Excel._Workbook.

"Vergel Adriano" wrote:

I usually just do something like this in VBA

ActiveWorkbook.Names.Add "SampleName", "=$A$1:$D$1"


if SampleName doesn't exist yet, it creates it. If it already exists, then
it gets overwritten with the new reference.


--
Hope that helps.

Vergel Adriano


"DeveloperSQL" wrote:

I need to programmatically redefine a named range (normally created On the
Insert menu, point to Name, and then click Define. Type the name e.g.
MyTable, select the range and then click OK.) in an excel file.
I need to change the range from e.g. A1:D18 to A1:D1.

How can this be done in C#? If you don't know C#, VB is ok too.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I have a cell value define a dynamic named range? CellShocked Excel Worksheet Functions 15 October 26th 11 02:08 AM
How do I use a Macro to define a Named Range EKUFan Excel Programming 1 September 16th 06 05:15 PM
Define Named Range Abdul[_2_] Excel Programming 1 August 30th 06 06:11 PM
How to define a relative named range in VBA John Broderick Excel Programming 10 December 24th 05 03:03 PM
How to define a Named Range in VBA? Richard Excel Programming 3 December 12th 05 06:49 PM


All times are GMT +1. The time now is 06:18 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"