Solved

Excel Macro: Replace Column Headers

Posted on 2012-03-14
5
289 Views
Last Modified: 2012-03-15
We have a long macro that messes up some of the column titles on the very first row. We probably have close to 20 columns.


Instead of having the users copy and paste row 1 back in each time, is there a macro that I pre-make and have them run it to replace it back with the predefined data?

For example:

Title 1    Title 2    Title 3  Title 4

When we run the Macro1 it may look like:

56    al   bl   number

Because our macros look at the entire columns.


So if I can have a a Macro2 that the users would run after the first one, that changes it back to :

Title 1    Title 2    Title 3  Title 4

That would be great.

There is nothing special about the titles other than they are bold.
0
Comment
Question by:Pancake_Effect
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 43

Accepted Solution

by:
Saqib Husain, Syed earned 500 total points
ID: 37721755
Put this in a macro

range("a1:j1").Value=array("Title 1","Title 2","Title 3","Title 4","Title 5","Title 6","Title 7","Title 8","Title 9","Title 10")
0
 
LVL 10

Expert Comment

by:borgunit
ID: 37721829
Has you thought about altering the macro to exclude your title row when it runs?
0
 
LVL 4

Author Comment

by:Pancake_Effect
ID: 37722165
ssaqibh works great!  Thank you so much.

borgunit - I'm not sure how to do that, I've been mostly just using what is provided to me on here. I'm a noob at it :(

You can take a look at my attached script, it's quite long and messy. But if I put ssaqibh's line of code on the bottom it takes care of the problem.
0
 
LVL 10

Expert Comment

by:borgunit
ID: 37722317
I guess my only concern was that the new info in the title row was necessary and/or if the macro sorted the title info to another place.
0
 
LVL 4

Author Closing Comment

by:Pancake_Effect
ID: 37726013
Thanks for the help.

This worked flawlessly.
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question