×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Renaming Column Headers in Excel using VBA

Renaming Column Headers in Excel using VBA

Renaming Column Headers in Excel using VBA

(OP)
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


To

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.

RE: Renaming Column Headers in Excel using VBA

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,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: Renaming Column Headers in Excel using VBA

(OP)
Thanks Skip. That worked great.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close