(Excel) Define several incremental cells' names at once

lemuffin

New Member
Joined
Oct 31, 2011
Messages
4
Good morning folks!

I am trying to rename a row of cells with incremental names. Ex.

A1=Results1, A2=Results2, A3=Results3, ...., AN=ResultsN

Of course, it can be done by setting names for each cell separately but it takes ages. I would like to know if this is possible to do that quickly thanks to an add-in or VBA.

P.S. I use Excel 2003.

Thanks a LOT for you help!
 

littleiitin

Active Member
Joined
Apr 12, 2010
Messages
401
Hi Lemuffin,

Welcome to the Board,

It will take seconds to do this:

Write
A1= Results1
A2= Results2

Now Select
Results1 and Results2
at the Bottom right border of the selection if you take your mouse your muse curser will turn into a + sign at this moment just Press theLeft Click and Drag till where you want.

Thanks

HTH
-----------------------
 

lemuffin

New Member
Joined
Oct 31, 2011
Messages
4
Thanks for your reply littleiitin,

Actually, this is not what I am trying to do. I would like to DEFINE CELLS NAME quickly, not set a name in the cells.

For instance, cell A1 would be named "Results1" and its content would be a numerical results. Cell A2 would be named "Results2", etc...

The problem is that if you want to do that manually for each cell, it takes ages and I'd like to know if there is a was of defining multiple incremental cells' name quickly.

Thanks a lot for your help!
 

littleiitin

Active Member
Joined
Apr 12, 2010
Messages
401
Try This:

If you are new to VBA:

Then right click on your sheet Tab--> View Code ---> Paste Below code in Blank area and Press F5

Code:
Sub NameRange()
    Dim rngCell As Range
    Dim lngCnt  As Long
    
    lngCnt = 1
    For Each rngCell In Range("A1:a15")
        rngCell.Name = "Results" & lngCnt
        lngCnt = lngCnt + 1
    Next
End Sub
 

lemuffin

New Member
Joined
Oct 31, 2011
Messages
4
Thanks again for your reply.

I was wondering doing similar with VBA. I guess that it's the best way to do it since there does not seem to be another "easy" solution.

Thanks for your help!
 

lemuffin

New Member
Joined
Oct 31, 2011
Messages
4
Thanks again for your reply.

I was wondering doing similar with VBA. I guess that it's the best way to do it since there does not seem to be another "easy" solution.

Thanks for your help!
 

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
35,505
Office Version
2010
Platform
Windows
Code:
Sub NameRange()
    Dim rngCell As Range
    Dim lngCnt  As Long
 
    lngCnt = 1
    For Each rngCell In Range("A1:a15")
        rngCell.Name = "Results" & lngCnt
        lngCnt = lngCnt + 1
    Next
End Sub
I think this would be a simpler way to write that code...

Code:
Sub NameRange()
    Dim RowRange As Long
    For RowRange = 1 To 15
      Cells(RowRange, "A").Name = "Results" & RowRange
    Next
End Sub
 

spontaneouslydia

New Member
Joined
Oct 9, 2014
Messages
4
Try This:

If you are new to VBA:

Then right click on your sheet Tab--> View Code ---> Paste Below code in Blank area and Press F5

Code:
Sub NameRange()
    Dim rngCell As Range
    Dim lngCnt  As Long
    
    lngCnt = 1
    For Each rngCell In Range("A1:a15")
        rngCell.Name = "Results" & lngCnt
        lngCnt = lngCnt + 1
    Next
End Sub
Thank you so much for this. I have been trying so hard to figure out what I was doing wrong. Thanks to you I figured it out!!!
 

Forum statistics

Threads
1,082,151
Messages
5,363,437
Members
400,737
Latest member
vipamuk

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top