Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default naming cells for their content

I have a worksheet that is 2 x100 in size, that is columns A and B, Rows
1 through 100. Each cell is filled with a single "word", in this case
the sheet looks like the following:

A B
1 data1 data2
2 data3 data4
3 data5 data5
4 data6 data7
5 data8 data9
6 data10 data11
7 data12 data13
8 data14 data15
etc,etc,etc....

I would like to name the cells the same as their content. In other words
the cell that contains the word data3 would be named data3. Once this is
done I want to delete the contents of all of the cells but keep the
names that I have created for each cell. Is this possible without having
to do each cell individually. Can some macro be used to perform this
easily?
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default naming cells for their content

Sub NameCells()
Dim rng as Ragne, cell as range
Set rng = Range("A1:B100")
for each cell in rng
cell.Name = cell.value
Next
rng.clearcontents
End Sub

Test it on a copy of your workbook.

--
Regards,
Tom Ogilvy

"Elfego Baca" wrote in message
...
I have a worksheet that is 2 x100 in size, that is columns A and B, Rows 1
through 100. Each cell is filled with a single "word", in this case the
sheet looks like the following:

A B
1 data1 data2
2 data3 data4
3 data5 data5
4 data6 data7
5 data8 data9
6 data10 data11
7 data12 data13
8 data14 data15
etc,etc,etc....

I would like to name the cells the same as their content. In other words
the cell that contains the word data3 would be named data3. Once this is
done I want to delete the contents of all of the cells but keep the names
that I have created for each cell. Is this possible without having to do
each cell individually. Can some macro be used to perform this easily?



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default naming cells for their content

Just a heads up, but
note that the approach provided by Don,

Sub nameeachcell()
For Each c In range("a2:b100")'Selection
c.Name = c
c.Clear
Next c
End Sub

will clear formatting in the range as well. If you just want to clear the
value/formula, then use ClearContents in place of Clear.

--
Regards,
Tom Ogilvy





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Naming sheets by cell content kefee85 Excel Discussion (Misc queries) 1 March 5th 09 09:31 PM
Range naming cells with blank cells through coding Naveen J V Excel Discussion (Misc queries) 1 March 27th 08 01:46 PM
Naming cells Watercolor artist Excel Discussion (Misc queries) 9 July 13th 05 01:19 PM
Re-Naming cells Keith Excel Worksheet Functions 1 March 7th 05 03:21 AM
naming cells John Excel Programming 7 February 17th 05 01:50 AM


All times are GMT +1. The time now is 08:25 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"