LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Member
 
Location: Bangalore
Posts: 41
Thumbs up

Quote:
Originally Posted by leuce View Post
G'day everyone

I'm trying to process some fairly complex Excel files in other editors (i.e. editors that simply extract the text from the Excel file) and it would be great if I could mark every cell with its reference. This would enable me to know which piece of text is in which cell, even if I'm not looking at it inside Excel.

So, is there a simple or quick way to add the cell reference of each cell to the start of that cell's content?

For example, if cell B5 has the content "The cat sat on the mat", then I would want cell B5's content to be updated to "[B5]The cat sat on the mat".

I understand that merged cells may pose difficulties but I don't care if merged cells' references are somewhat imprecise as long as I can figure out more or less where the cell is (e.g. as long as I know its row reference, or its column reference, or the reference of the top-left cell in the merged cell). Anyway the text that I'm concerned about generally don't occur in merged cells, so even if merged cells can't get references, it would still be okay.

I suppose this would have to be done using a macro -- I'm not afraid of adding macros to Excel although I'm not really a macro author (when I create macros in MS Word, for example, I do it mostly by recording).

Do you know of a program or tool or macro that would do what I specified above, i.e. to add each cell's cell reference to the start (or end) of the cell?

Thanks
Samuel (leuce)
Try the following code.

You need to select a range (you may select a non contiguous range as well).

The macro will put the cell's address and will concatenate the cell's content.

This works well with the Merged cells (top left corner's range address is used).

It ignores any blank cell in your selection.

Let me know if you face any issues.

To get this working. Put this code into a standard VBA module. Make a selection and run the macro (Alt + F8).

Option Explicit

Sub AddTitle()
Dim Temp As Variant
Dim cell As Range
If TypeName(Selection) < "Range" Then
MsgBox "Select the range to work with.", vbCritical
Exit Sub
End If

For Each cell In Selection.Cells
If Not cell.Value = "" Then
Temp = " " & cell.Value
cell.Value = cell.Address(False, False, xlA1) & Temp
End If
Next cell
End Sub


Thank You,
Prashant
 
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
How do I Reference another cell's content including its format Brian D Excel Worksheet Functions 2 November 15th 08 01:07 AM
Replacing Part of a Cell's Content mommy2kh Excel Worksheet Functions 5 July 13th 08 05:42 PM
Need to refer to a cell's address, not it's content... aduroche Excel Discussion (Misc queries) 3 October 18th 07 08:54 PM
cell's reference value dependent on another cell's value Flash in the Pan Excel Programming 4 April 6th 06 09:23 PM
Changing named range reference depending on a cell's content cparaske Excel Discussion (Misc queries) 1 July 29th 05 07:06 PM


All times are GMT +1. The time now is 07:19 PM.

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

About Us

"It's about Microsoft Excel"