(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!
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
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
-----------------------
 
Upvote 0
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!
 
Upvote 0
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
 
Upvote 0
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!
 
Upvote 0
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!
 
Upvote 0
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
 
Upvote 0
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!!!
 
Upvote 0

Forum statistics

Threads
1,213,543
Messages
6,114,237
Members
448,555
Latest member
RobertJones1986

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top