PC Review


Reply
Thread Tools Rate Thread

Automatically create names from values in cell

 
 
andreashermle
Guest
Posts: n/a
 
      17th Jul 2010
Dear Experts:

This simple code snippet automatically creates names from values in
the left column of a selection

Sub CreateNames()
Selection.CreateNames Left:=True
End Sub

The built-in functionality is: Formulas - Create from Selection -
Create names from values in the left column.

For the macro solution to work, one must select cells from at least
two columns. Hence this simple macro should be re-written so that the
current selection of cells ( cells have been selected from just one
column) automatically gets extended to the right. For example: Current
selection A2:A5. The code snippet for the extension of the selection
should extend the selection to A2:B5.

Help is much appreciated. Thank you very much in advance.

Regards, Andreas

 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      17th Jul 2010
I wouldn't use CreateNames as the macro name -- it looks way too much like the
..CreateNames method for a range.

Option Explicit
Sub MyCreateNames()
Selection.Columns(1).Resize(, 2).CreateNames Left:=True
End Sub

The .columns(1) tells excel to just look at the first column in the selection.

The .resize(, 2) tells excel to include the adjacent column.



On 07/17/2010 14:18, andreashermle wrote:
> Dear Experts:
>
> This simple code snippet automatically creates names from values in
> the left column of a selection
>
> Sub CreateNames()
> Selection.CreateNames Left:=True
> End Sub
>
> The built-in functionality is: Formulas - Create from Selection -
> Create names from values in the left column.
>
> For the macro solution to work, one must select cells from at least
> two columns. Hence this simple macro should be re-written so that the
> current selection of cells ( cells have been selected from just one
> column) automatically gets extended to the right. For example: Current
> selection A2:A5. The code snippet for the extension of the selection
> should extend the selection to A2:B5.
>
> Help is much appreciated. Thank you very much in advance.
>
> Regards, Andreas
>


--
Dave Peterson
 
Reply With Quote
 
andreashermle
Guest
Posts: n/a
 
      19th Jul 2010
On 17 Jul., 22:00, Dave Peterson <peter...@XSPAMverizon.net> wrote:
> I wouldn't use CreateNames as the macro name -- it looks way too much like the
> .CreateNames method for a range.
>
> Option Explicit
> Sub MyCreateNames()
> * * *Selection.Columns(1).Resize(, 2).CreateNames Left:=True
> End Sub
>
> The .columns(1) tells excel to just look at the first column in the selection.
>
> The .resize(, 2) tells excel to include the adjacent column.
>
> On 07/17/2010 14:18, andreashermle wrote:
>
>
>
>
>
> > Dear Experts:

>
> > This simple code snippet automatically creates names from values in
> > the left column of a selection

>
> > Sub CreateNames()
> > * Selection.CreateNames Left:=True
> > End Sub

>
> > The built-in functionality is: Formulas - Create from Selection -
> > Create names from values in the left column.

>
> > For the macro solution to work, one must select cells from at least
> > two columns. Hence this simple macro should be re-written so that the
> > current selection of cells ( cells have been selected from just one
> > column) automatically gets extended to the right. For example: Current
> > selection A2:A5. The code snippet for the extension of the selection
> > should extend the selection to A2:B5.

>
> > Help is much appreciated. Thank you very much in advance.

>
> > Regards, Andreas

>
> --
> Dave Peterson- Zitierten Text ausblenden -
>
> - Zitierten Text anzeigen -


Hi Dave,

thank you very much for your greate support.

Regards, Andreas
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: file names and folder names have been changed into some values automatically Malke Windows Vista File Management 0 11th Jul 2008 01:10 PM
Use Cell Values to Create Tabs with specific names =?Utf-8?B?TXIuIE1hdHQ=?= Microsoft Excel Programming 4 13th Apr 2007 02:06 AM
Bubbble chart -How to automatically add series names, X, Y values =?Utf-8?B?UkhJ?= Microsoft Excel Charting 1 16th Nov 2005 10:20 PM
Concatenating cell values to create sheet names =?Utf-8?B?WExEYWJibGVy?= Microsoft Excel Misc 3 29th Aug 2005 09:55 PM
Put tab names in cell automatically Dave - A1 Microsoft Excel Discussion 1 14th Aug 2003 08:09 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:08 AM.