0

Ok I promise this is my last question for today! Can you please let me know how I can Remove space between header title in a Row? For example suppose I have a row like this

|Airst Name|        |Zoom Area|Polygon Type|......

so to loop trough all titles inside the row as whe as there are and convert them to

|Airst_Name|        |Zoom_Area|Polygon_Type|......

Please remember that this is going to be done entire of just in one row lets say row 3.

Thanks

Community
  • 1
  • 1
Behseini
  • 6,066
  • 23
  • 78
  • 125
  • I answered a question similar to this yesterday :) – Siddharth Rout Dec 17 '13 at 05:30
  • This doesn't even really beg a `VBA` procedure. A simple `Ctrl-H` might suffice. ;) – WGS Dec 17 '13 at 05:30
  • These type of questions have been answered many times int he past. [HERE](http://stackoverflow.com/questions/20154207/how-do-i-remove-a-character-from-a-column-of-data-in-excel), [HERE](http://stackoverflow.com/questions/20227402/using-excel-macros-to-replace-text-quickly-if-the-cell-is-a-certain-value) and at many more places. – Siddharth Rout Dec 17 '13 at 05:48
  • @SiddharthRout: Definitely needs a community wiki of sorts, mayhaps? – WGS Dec 17 '13 at 05:56
  • lol@BK201: There are so many things... You will get tired creating a wiki for everything :) – Siddharth Rout Dec 17 '13 at 05:57

1 Answers1

2

You can do it manually by using Ctrl-H. Via VBA, you can use:

Sub Test()
    Dim R3 As Range
    Set R3 = Rows(3)
    R3.Replace What:=" ", Replacement:="_"
End Sub

Let us know if this helps.

WGS
  • 13,969
  • 4
  • 48
  • 51
  • + 1 However one word of caution. `.Find` and `.Replace` are very dicey in Excel. If not used properly, they can give you unexpected results. Let me explain. They both always remember the last setting used. And hence it is always better to fully specify the `What:=`,`Replacement:=`, `LookAt:=` etc... as shown [HERE](http://stackoverflow.com/questions/20154207/how-do-i-remove-a-character-from-a-column-of-data-in-excel) – Siddharth Rout Dec 17 '13 at 06:06
  • @SiddharthRout: This is one of the pitfalls of this really convenient method, but it will be solely up to OP to discover this. I myself discovered the horror of this when I used `Ctrl-F` after running a macro only to discover that the settings are also in there! Oh, the horror of being the VBA noob~~! ;) – WGS Dec 17 '13 at 06:09