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.
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 :)
Subreddit
Post Details
- Posted
- 5 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/vba/comment...