Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

6
Macro to change column headers
Post Flair (click to view more posts with a particular flair)
Post Body

Hi there,

I would like to write a macro which changes my column headers. In reality, I have more than three columns, but I am using this example to simplify.

I know I could just have a seperate worksheet/book but **I would really like to know if this can be done in a macro.**

I figure that the best way to do this would be to write some code to insert a new row with pre-populated headers, then delete the old header (now row 2).

Original:

     ----------- ------------------------ --------- 
    | Name (A)  |         Email  (B)     |Animal(C)|
     ----------- ------------------------ --------- 
    | Lauretta  | [email protected]  | Pig     |
    | Kanisha   | [email protected]   | Pig     |
    | Katelynn  | [email protected]  | Pig     |
    | Irwin     | [email protected]     | Cat     |
    | Renea     | [email protected]     | Cat     |

Transition state:

This step I have partially figured out -

Range("A1").EntireRow.Insert

But **I don't know how to insert pre-set values WITH the row.** I have looked all over the internet and can't figure out if it's even possible.

     ----------- ------------------------ --------- 
    | Nom  (A)  |      creemail  (B)     |  wut (C)|
     ----------- ------------------------ --------- 
     ----------- ------------------------ --------- 
    | Name (A)  |         Email  (B)     |Animal(C)|
     ----------- ------------------------ --------- 
    | Lauretta  | [email protected]  | Pig     |
    | Kanisha   | [email protected]   | Pig     |
    | Katelynn  | [email protected]  | Pig     |
    | Irwin     | [email protected]     | Cat     |
    | Renea     | [email protected]     | Cat     |

Final:

This step I have got figured out -

Range("A2").EntireRow.Delete

or

Rows(2).EntireRow.Delete`

     ----------- ------------------------ --------- 
    | Nom  (A)  |      creemail  (B)     |  wut (C)|
     ----------- ------------------------ --------- 
    | Lauretta  | [email protected]  | Pig     |
    | Kanisha   | [email protected]   | Pig     |
    | Katelynn  | [email protected]  | Pig     |
    | Irwin     | [email protected]     | Cat     |
    | Renea     | [email protected]     | Cat     |

any help or pointers would be very gratefully received! Thank you :)

Author
Account Strength
100%
Account Age
5 years
Verified Email
Yes
Verified Flair
No
Total Karma
18,222
Link Karma
10,468
Comment Karma
6,920
Profile updated: 6 days ago
Posts updated: 1 year ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
5 years ago