如题,本人有一批EXCEL表,要对其中的工作表先加边框,再进行转置。急用,在先等。

解决方案 »

  1.   

    刚接触VBA,具体实现还不回,但工作中又需要,指点
      

  2.   

    可以幫你搞定。
    [email protected]
      

  3.   

    Step1:建立工作簿(包含sheet1,sheet2)
    sheet1用来存放原表
    sheet2用来转置Step2:
    sheet1代码
    Private Sub CommandButton1_Click()
        Selection.Borders(xlDiagonalDown).LineStyle = xlNone
        Selection.Borders(xlDiagonalUp).LineStyle = xlNone
        With Selection.Borders(xlEdgeLeft)
            .LineStyle = xlContinuous
            .Weight = xlThin
            .ColorIndex = xlAutomatic
        End With
        With Selection.Borders(xlEdgeTop)
            .LineStyle = xlContinuous
            .Weight = xlThin
            .ColorIndex = xlAutomatic
        End With
        With Selection.Borders(xlEdgeBottom)
            .LineStyle = xlContinuous
            .Weight = xlThin
            .ColorIndex = xlAutomatic
        End With
        With Selection.Borders(xlEdgeRight)
            .LineStyle = xlContinuous
            .Weight = xlThin
            .ColorIndex = xlAutomatic
        End With
        With Selection.Borders(xlInsideVertical)
            .LineStyle = xlContinuous
            .Weight = xlThin
            .ColorIndex = xlAutomatic
        End With
        With Selection.Borders(xlInsideHorizontal)
            .LineStyle = xlContinuous
            .Weight = xlThin
            .ColorIndex = xlAutomatic
        End With
        Selection.Copy
        Sheet2.Select
    End Sub
    &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
    sheet2代码
    Private Sub CommandButton1_Click()
        Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
            False, Transpose:=True
    End Sub
    &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&Step3:操作
    在sheet1中选中要改变的表格区域,点button,跳转到sheet2.
    在sheet2中选中要建立转置表的首单元格,点button,进行转置后的粘贴.