Rearranging columns in a data Excel Table

Tammy Lester

New Member
Joined
Apr 8, 2016
Messages
2
I have been able to add columns successfully but I cannot move columns around in my data table.

For example, I have a table with column headers and I need to move column J (last column) between column G and H. I have tried the simple drag and drop, cut and paste and I receive an error message.
4AAAAASUVORK5CYII=
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Hi,

Not knowing anything about your table other than column J is the last column does not really tell us anything. For instance, if column F is you first column in the table, then column J is really Column(5) of your table. That said, this would be a generic way of accomplishing what you want to do. You would have substitute my ListColumn numbers to what would match on your table. I am also working with a table named "Table1"

Other than that, there is no reason that if you manually select the entire column of a table and move the cursor toward the top of the column to the point where it turns into a black cross with arrows at the ends of the cross, you should be able to manually drag and drop that column wherever you want.

Code:
Sub tblcol()


    Dim tbl As ListObject
    
    Set tbl = ActiveSheet.ListObjects("Table1")
    tbl.ListColumns.Add Position:=4
    tbl.ListColumns(9).Range.Copy tbl.ListColumns(4).Range
    tbl.ListColumns(9).Delete
    
End Sub

I hope this helps.
 
Upvote 0

Forum statistics

Threads
1,213,562
Messages
6,114,326
Members
448,564
Latest member
ED38

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top