Solved

Excel Macro: Replace Column Headers

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
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…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

810 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