Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Renaming Column Headers in Excel using VBA 1

Status
Not open for further replies.

fishtek

Technical User
Aug 21, 2002
56
US
I'm manipulating tables in Excel using Visual basic and as part of the code I would like to remove all text enclosed in parentheses from column headers - see below

From
Headers_w6foyq.jpg



To
Headers2_dalvzm.jpg


Ive been attempting to use the example formula using VBA but cannot make it work
Code:
=LEFT(D1,FIND(" (",D1)-1)
and so forth for each header.

Thanks for any help.
 
Hi,

Assuming that this sheet is the active sheet...
Code:
Dim r As Range

For Each r In Range([A1], [A1].End(xlToRight))
   With r
      .Value = Trim(Split(.Value, "(")(0))
   End With
Next

Skip,

[glasses]Just traded in my OLD subtlety...
for a NUance![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top