Solved

Excel Macro: Replace Column Headers

Posted on 2012-03-14
5
284 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

732 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