Avatar of Andreas Hermle
Andreas Hermle
Flag for Germany asked on

Turn named table on active worksheet upside down using VBA

Dear Experts:

I wonder whether it is possible by means of a VBA code to turn a list upside down.

I know the workaround:
- Insert a helper column to the very right.
- Put 1, 2, 3, 4, ... all the way down that column.
- Then select the data and sort by this column in descending order.
- Then delete the helper column.

But now I would like to know how to do this using VBA.

In my special case, I got a named table (MyTable1) on the active worksheet that should be flipped upside down.

Help is much appreciated. Thank you very much in advance.

Regards, Andreas
Microsoft Excel

Avatar of undefined
Last Comment
Andreas Hermle

8/22/2022 - Mon
SOLUTION
Joe Howard

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Saqib Husain

If you give us a sample file I can provide you with a macro.
Andreas Hermle

ASKER
Hi MacroShadow:

thank you very much for your swift help.
- I could record a macro of course, but as you know, recorded macros are often kind of  'clumsy' and or not 'very professional'
- The macro code works fine although I can flip the order (only) on one column at a time, i.e. on a 5 column list I need to run the macro 5 times.
Nevertheless, I do not want to complain. It is a great code that does excactly what I want.

I'll give ssaqibh a chance to see what he comes up with.

Regards, Andreas
Andreas Hermle

ASKER
ssaqibh:

here we are. Thank you very much for your help.

Regards, Andreas
Named-Table-table1-flip-upside-d.xlsx
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
ASKER CERTIFIED SOLUTION
byundt

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Andreas Hermle

ASKER
Hi Brad,

works like a charm, thank you very much for your superb and professional help! I am really impressed!

ssaqibh: I was gonna try out your code but you inadvertently sent an xlsx-file that - as you know - is not able to hold any macro code.

Before awarding the points I would like to have a look at your code as well.

Again, I am really impressed at the professionalism of this forum.
Andreas Hermle

ASKER
Dear both,

thank you very much for your great and professional support.

Brad: very nice coding, works like a charm and will be applied by me lots of times on my working place. Thank you.