Naming cell regions dynamically from VB


Posted by Vik Kala on February 27, 2001 7:06 AM


Hi Guys,
I am working on a VB application in which I am creating
and manipulating an Excel sheet as an object. My question
is,how can I name a cell region dynamically from within
VB code (or for that matter from within any other scripting
language).
My second question might not be related to Excel directly.
I am trying to open an existing Excel application using
GetObject(path) command. For some reason it does not
bring up the spreadsheet.
I will appreciate inputs on any of the above two.
Thanks,
Vik



Posted by Eli Weiss on February 28, 2001 3:28 AM

Hi Vik,

Is this code answers your first question?
It allows to choose a cell region dynamically from the worksheet and then assigns a name to this range.

:Sub Demo()
'
'
'
Dim MyRange As Range
Set MyRange = Application.InputBox _
(Prompt:="Select any range", Type:=8)
MyRange.Name = "Database"

End Sub

Eli