Link to home
Start Free TrialLog in
Avatar of upobDaPlaya
upobDaPlaya

asked on

Change Position of Column and Column Name

I have an Excel spreadsheet that I receive and each time I receive the file I am forced to place the columns in a different position and also rename the column headers.  Within Excel VBA how can I change the column header names and the column position.  See tab names called Original and Modified.
EE-ColPosColName.xlsx
Avatar of Wayne Taylor (webtubbs)
Wayne Taylor (webtubbs)
Flag of Australia image

Nothing attached.
Avatar of upobDaPlaya
upobDaPlaya

ASKER

Sorry..have attached now
Is it only those 3 columns? Will there ever be more columns of data? Are they always in the order showing in the "Original" sheet?
Click the button (or run the macro in Module1)

With my code it doesn't matter how many columns there are, what they are called, or what order they are in.
29087143.xlsm
Looks like we'll still need the answers to my questions above as Martin's code doesn't produce the desired output.
You're right. I thought the columns just needed to be reversed.
There will always be more than 3 columns but they will always be in the same order for the Original tab.  I only used 3 as an example.
ASKER CERTIFIED SOLUTION
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi Matin, this is awesome !  Can you explain to me the .UsedRange.Columns.Count - How is UsedRange defined ?  Does it go to the first column and then go right to determine how many used columns I have ?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Please don't forget to close this question.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thx
Learned a lot..the various approaches gave me something to think about (had not considered an array) but I implemented Martins as it best fit my problem.  Will fool around with the array though..
I’m glad I was able to help.

If you expand the “Full Biography” section of my profile you’ll find links to some articles I’ve written that may interest you.

Marty - Microsoft MVP 2009 to 2017
              Experts Exchange Most Valuable Expert (MVE) 2015, 2017
              Experts Exchange Top Expert Visual Basic Classic 2012 to 2017
Thank you..I will take a look...I am trying to soak up as much VBA as I can so it appears your articles will be a good resource.