ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Cell Naming (https://www.excelbanter.com/excel-programming/363207-cell-naming.html)

Grymjack

Cell Naming
 
Ok, I have a problem. I have to name a large number of cells in
different sheets. I'm hoping that there is a way in a macro, or some
other way to define these in an easier way other than one by one. Here
is an example:

1 2 3 4
1001 --------- --------- --------- ---------
1002 --------- --------- --------- ---------
1209 --------- --------- --------- ---------
1210 --------- --------- --------- ---------


This would be the column and row headers for the cells. Below is how
the cells would have to be named:


1 2 3 4
1001 S_1001_01 S_1001_02 S_1001_03 S_1001_04
1002 S_1002_01 S_1002_02 S_1002_03 S_1002_04
1209 S_1209_01 S_1209_02 S_1209_03 S_1209_04
1210 S_1210_01 S_1210_02 S_1210_03 S_1210_04


There are thousands of cells I have to name in a similar fashion. Is
there a shortcut way to define these cells through a macro? Thanks in
advance for any help any of you may pass my way.

-Dan Canham




excelent

Cell Naming
 
Some like this:

Sub MultiName()

Dim r As Long
For r = 1001 To 2000
Cells(r, 1).Name = "S_" & r & "_01"
Cells(r, 2).Name = "S_" & r & "_02"
Cells(r, 3).Name = "S_" & r & "_03"
Cells(r, 4).Name = "S_" & r & "_04"
Next

End Sub


Grymjack

Cell Naming
 
excelent wrote:
Some like this:

Sub MultiName()

Dim r As Long
For r = 1001 To 2000
Cells(r, 1).Name = "S_" & r & "_01"
Cells(r, 2).Name = "S_" & r & "_02"
Cells(r, 3).Name = "S_" & r & "_03"
Cells(r, 4).Name = "S_" & r & "_04"
Next

End Sub

Thanks for the help


All times are GMT +1. The time now is 05:11 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com