Solved

Excel Macro: Replace Column Headers

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

821 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