VBA to reorder columns in a List View

Nick3995

New Member
Joined
Jun 20, 2012
Messages
1
I have a listobject bound to a sharepoint list. I am trying to use vba to move the columns around. It is possible to click on a header and drag a column from one location in the list to another. When I record this action in a macro and then attempt to run the code again. It fails. There are no errors generated but it fails to actually move the column. It inserts a new column in the correct place but fails to copy the source into the new column and fails to remove the source from its original column. Here is the vba code that is generated:

Sub Macro5()
' Macro5 Macro
Range("ProjectList[[#Headers],[Account]]").Select
Selection.Cut
Range("ProjectList[[#All],[Title]]").Select
Selection.Insert Shift:=xlToRight
End Sub

I’m just wondering if anyone has done this before. If so offer some suggestions. I’ve researched the web for awhile and I’m coming up empty.
 

Some videos you may like

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

Watch MrExcel Video

Forum statistics

Threads
1,122,487
Messages
5,596,450
Members
414,068
Latest member
FAH

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
Top