全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 Excel
932 0
2011-12-05
大家帮我看看这段代码,总是出错,不知道怎么修改,谢谢啦!

Sub 加红框2()

Dim ss As String

For i = 1 To 23
  ss = Worksheets("机构名").Range("A" & i)
'机构名这张表里A1:A23是23个名称,分别对应workbook中的其中23个sheet.
  
  k = worksheets(ss).Range("N2").Value
'这里N2里是行数,已经排除,问题不在这句

  worksheets(ss).Range("A" & k & ":I" & k).Select
'这一句,如果用循环ss,就错,不用循环,单独一个一个机构操作此宏就没问题,现在认为问题就出在循环这,请高手帮我看看,非常感谢。
    Selection.Borders(xlDiagonalDown).LineStyle = xlNone
    Selection.Borders(xlDiagonalUp).LineStyle = xlNone
    With Selection.Borders(xlEdgeLeft)
        .LineStyle = xlContinuous
        .Weight = xlMedium
        .ColorIndex = 3
    End With
    With Selection.Borders(xlEdgeTop)
        .LineStyle = xlContinuous
        .Weight = xlMedium
        .ColorIndex = 3
    End With
    With Selection.Borders(xlEdgeBottom)
        .LineStyle = xlContinuous
        .Weight = xlMedium
        .ColorIndex = 3
    End With
    With Selection.Borders(xlEdgeRight)
        .LineStyle = xlContinuous
        .Weight = xlMedium
        .ColorIndex = 3
    End With
    With Selection.Borders(xlInsideVertical)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
   
   Next i
   
End Sub

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群