各位大哥大姐们,小弟我不会知道在Excel中如何用VBA实现两行或者两列互换内容,请帮忙解决,谢谢了,最好有代码或者相应的例子!

解决方案 »

  1.   

    xxx =sheet1.cells(2,1)
    sheet1.cells(2,1) = sheet1.cells(1,2)
    sheet1.cells(1,2) = xxx
      

  2.   

        '第一行与第二行交换
        Rows("1:1").Select
        Selection.Cut
        Rows("3:3").Select
        Selection.Insert Shift:=xlDown
        Range("A1").Select
        '第五行与第六行交换
        Rows("5:5").Select
        Selection.Cut
        Rows("7:7").Select
        Selection.Insert Shift:=xlDown
        Range("A1").Select
        '第A列与第B列交换
        Columns("A:A").Select
        Selection.Cut
        Columns("C:C").Select
        Selection.Insert Shift:=xlToRight
        '第E列与第F列交换
        Columns("E:E").Select
        Selection.Cut
        Columns("G:G").Select
        Selection.Insert Shift:=xlToRight
      

  3.   

    呵呵,楼主的问题我就不答了,给楼主推荐一个东西:http://download.csdn.net/source/1627060