Need Macro to replaces the ## with the Column Heading

krishhi

Active Member
Joined
Sep 8, 2008
Messages
328
Hi Guys,

Please check the excel sheet, I need a macro to work. where "##" should be replaces with the Column Heading in this case Heading is "RochesterNY" without last two letters i.e. "Rochester", where # should be replaces with the whole Column Heading i.e "RochesterNY".​

Here is the file link:

HTML:
http://www.4shared.com/file/BNHtxzak/Lawyers_data_base.html


Any help?

Waiting for your kind reply.

Thanks,
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Ok,

I got an excellent answer from another place. May be it will useful to some one.

Here is the code:

Code:
 [LEFT]Sub ChangeNums() 
    Dim col As Range, cell As Range 
    For Each col In ActiveSheet.UsedRange.Columns 
        For Each cell In col.Cells 
            If cell.Address <> col.Cells(1, 1).Address Then 
                cell.Value = Replace(cell.Value, "##", Left(col.Cells(1, 1).Value, Len(col.Cells(1, 1).Value) - 2)) 
                cell.Value = Replace(cell.Value, "#", col.Cells(1, 1).Value) 
            End If 
        Next cell 
    Next col 
    ActiveSheet.UsedRange.Columns.AutoFit 
End Sub [/LEFT]
 
Upvote 0

Forum statistics

Threads
1,224,609
Messages
6,179,882
Members
452,948
Latest member
Dupuhini

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