Question : Swap two columns using vba

I need to swap two columns in a worksheet.

The columns I want to swap are genereted when a mcaro is invoked.

After recording a macro and making some changes this is what I have :

    Cells(val, val).Select
    Selection.Cut
    Cells(2, 2).Select
    Selection.Insert Shift:=xlToRight

Where val is an integer that is set by a function.

The above code does'nt work.

Any suggestions would be greatly appreciated.

Answer : Swap two columns using vba

If you want to swap columns, you can use code like:

    Columns(6).Cut
    Columns(5).Insert Shift:=xlToRight

replacing 6 and 5 with whatever your column numbers are.
Regards,
Rory
Random Solutions  
 
programming4us programming4us