Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel vba子函数调用时间chell下线错误_Excel_Vba - Fatal编程技术网

Excel vba子函数调用时间chell下线错误

Excel vba子函数调用时间chell下线错误,excel,vba,Excel,Vba,我在vba中有默认的测试函数调用。vba BICO()函数中的数据首次加载已成功加载数据,但行未淹没在第一张工作表中。 第二个函数是调用数据加载的数据,但第二个函数中的行被淹没 这是我的错误。 我在我的代码中分享了如何销售我的织布机。任何解决方案或任何参考 Sub test() Dim im, jm As Integer im = 1 jm = 2 Call BICO(i) Call ssp(j) End Sub Sub ssp(im) Dim

我在vba中有默认的测试函数调用。vba BICO()函数中的数据首次加载已成功加载数据,但行未淹没在第一张工作表中。 第二个函数是调用数据加载的数据,但第二个函数中的行被淹没 这是我的错误。 我在我的代码中分享了如何销售我的织布机。任何解决方案或任何参考

Sub test()
    Dim im, jm As Integer
    im = 1
    jm = 2
    Call BICO(i)
    Call ssp(j)
End Sub

Sub ssp(im)
    Dim i As Integer
    i = 2
    Dim a1 As String
    Dim a2 As String
    a1 = "A" & i
    a2 = "C" & i

    Range(a1, a2).Select
    Selection.Borders(xlDiagonalDown).LineStyle = xlNone
    Selection.Borders(xlDiagonalUp).LineStyle = xlNone

    With Selection.Borders(xlEdgeLeft)
        .LineStyle = xlSolid
        .ColorIndex = xlAutomatic
        .TintAndShade = 0
    End With
    With Selection.Borders(xlEdgeBottom)
        .LineStyle = xlSolid
        .ColorIndex = xlAutomatic
        .TintAndShade = 0
    End With
    With Selection.Borders(xlEdgeRight)
        .LineStyle = xlSolid
        .ColorIndex = xlAutomatic
        .TintAndShade = 0
    End With
    With Selection.Borders(xlInsideVertical)
        .LineStyle = xlSolid
        .ColorIndex = xlAutomatic
        .TintAndShade = 0
    End With

    Sheets(1).Cells(2, 1).Value = "Saravanan"
    Sheets(1).Cells(2, 2).Value = "Saravanan  S/No Ramsing, Pondichary -60089"
    Sheets(1).Cells(2, 3).Value = "9791709616"
End Sub

Sub BICO(jm)
    Dim i As Integer
    i = 2
    Dim a1 As String
    Dim a2 As String
    a1 = "A" & i
    a2 = "C" & i

    Range(a1, a2).Select
    Selection.Borders(xlDiagonalDown).LineStyle = xlNone
    Selection.Borders(xlDiagonalUp).LineStyle = xlNone

    With Selection.Borders(xlEdgeLeft)
        .LineStyle = xlSolid
        .ColorIndex = xlAutomatic
        .TintAndShade = 0
    End With
    With Selection.Borders(xlEdgeBottom)
        .LineStyle = xlSolid
        .ColorIndex = xlAutomatic
        .TintAndShade = 0
    End With
    With Selection.Borders(xlEdgeRight)
        .LineStyle = xlSolid
        .ColorIndex = xlAutomatic
        .TintAndShade = 0
    End With
    With Selection.Borders(xlInsideVertical)
        .LineStyle = xlSolid
        .ColorIndex = xlAutomatic
        .TintAndShade = 0
    End With

    Sheets(2).Cells(2, 1).Value = "Saravanan"
    Sheets(2).Cells(2, 2).Value = "Saravanan  S/No Ramsing, Pondichary -60089"
    Sheets(2).Cells(2, 3).Value = "9791709616"
End Sub
我需要两张纸淹没线使用vba。

数据不行不显示

这是皮棉,现在可以淹死了


需要使用sheet1和sheet2来绘制网格线。

您遇到的问题是,您没有限定要选择的工作表的边框,下面更改的代码将为您指明正确的方向

此时,当您使用
Range(a1,a2)
时,您的代码只需查看活动工作表,而不告诉代码您所指的工作表,因此实际上代码正在工作,但在同一工作表上绘制两次边框,下面修改的代码将按照我指定的更新工作表工作

Sub test()
    Dim i As Long, j As Long
    i = 2
    j = 2
    Call BICO(i)
    Call ssp(j)
End Sub

Sub ssp(im)
    Dim wsSSP As Worksheet: Set wsSSP = ThisWorkbook.Sheets(1)
    Dim a1 As String
    Dim a2 As String
    a1 = "A" & im
    a2 = "C" & im

    wsSSP.Range(a1, a2).Borders(xlDiagonalDown).LineStyle = xlNone
    wsSSP.Range(a1, a2).Borders(xlDiagonalUp).LineStyle = xlNone
    With wsSSP.Range(a1, a2).Borders(xlEdgeLeft)
        .LineStyle = xlSolid
        .ColorIndex = xlAutomatic
        .TintAndShade = 0
    End With
    With wsSSP.Range(a1, a2).Borders(xlEdgeBottom)
        .LineStyle = xlSolid
        .ColorIndex = xlAutomatic
        .TintAndShade = 0
    End With
    With wsSSP.Range(a1, a2).Borders(xlEdgeRight)
        .LineStyle = xlSolid
        .ColorIndex = xlAutomatic
        .TintAndShade = 0
    End With
    With wsSSP.Range(a1, a2).Borders(xlInsideVertical)
        .LineStyle = xlSolid
        .ColorIndex = xlAutomatic
        .TintAndShade = 0
    End With
    wsSSP.Cells(2, 1).Value = "Saravanan"
    wsSSP.Cells(2, 2).Value = "Saravanan  S/No Ramsing, Pondichary -60089"
    wsSSP.Cells(2, 3).Value = "9791709616"
End Sub

Sub BICO(jm)
    Dim wsBICO As Worksheet: Set wsBICO = ThisWorkbook.Sheets(2)
    Dim a1 As String
    Dim a2 As String
    a1 = "A" & jm
    a2 = "C" & jm

    wsBICO.Range(a1, a2).Borders(xlDiagonalDown).LineStyle = xlNone
    wsBICO.Range(a1, a2).Borders(xlDiagonalUp).LineStyle = xlNone
    With wsBICO.Range(a1, a2).Borders(xlEdgeLeft)
        .LineStyle = xlSolid
        .ColorIndex = xlAutomatic
        .TintAndShade = 0
    End With
    With wsBICO.Range(a1, a2).Borders(xlEdgeBottom)
        .LineStyle = xlSolid
        .ColorIndex = xlAutomatic
        .TintAndShade = 0
    End With
    With wsBICO.Range(a1, a2).Borders(xlEdgeRight)
        .LineStyle = xlSolid
        .ColorIndex = xlAutomatic
        .TintAndShade = 0
    End With
    With wsBICO.Range(a1, a2).Borders(xlInsideVertical)
        .LineStyle = xlSolid
        .ColorIndex = xlAutomatic
        .TintAndShade = 0
    End With
    wsBICO.Cells(2, 1).Value = "Saravanan"
    wsBICO.Cells(2, 2).Value = "Saravanan  S/No Ramsing, Pondichary -60089"
    wsBICO.Cells(2, 3).Value = "9791709616"
End Sub
更新:

为了使代码更有用,当您为不同的工作表重复代码时,您可以修改Sub以将工作表作为参数,这样您就可以调用同一Sub以影响不同的工作表,请查看以下代码:

Sub test()
    Dim i As Long
    i = 2
    Call DrawBorder(i, ThisWorkbook.Sheets(1))
    Call DrawBorder(i, ThisWorkbook.Sheets(2))
End Sub

Sub DrawBorder(im As Long, ws As Worksheet)
    Dim a1 As String, a2 As String
    a1 = "A" & im
    a2 = "C" & im

    ws.Range(a1, a2).Borders(xlDiagonalDown).LineStyle = xlNone
    ws.Range(a1, a2).Borders(xlDiagonalUp).LineStyle = xlNone

    With wsSSP.Range(a1, a2).Borders(xlEdgeLeft)
        .LineStyle = xlSolid
        .ColorIndex = xlAutomatic
        .TintAndShade = 0
    End With
    With ws.Range(a1, a2).Borders(xlEdgeBottom)
        .LineStyle = xlSolid
        .ColorIndex = xlAutomatic
        .TintAndShade = 0
    End With
    With ws.Range(a1, a2).Borders(xlEdgeRight)
        .LineStyle = xlSolid
        .ColorIndex = xlAutomatic
        .TintAndShade = 0
    End With
    With ws.Range(a1, a2).Borders(xlInsideVertical)
        .LineStyle = xlSolid
        .ColorIndex = xlAutomatic
        .TintAndShade = 0
    End With

    ws.Cells(2, 1).Value = "Saravanan"
    ws.Cells(2, 2).Value = "Saravanan  S/No Ramsing, Pondichary -60089"
    ws.Cells(2, 3).Value = "9791709616"
End Sub

您遇到的问题是,您没有限定您选择的工作表的边框,下面更改的代码将为您指明正确的方向

此时,当您使用
Range(a1,a2)
时,您的代码只需查看活动工作表,而不告诉代码您所指的工作表,因此实际上代码正在工作,但在同一工作表上绘制两次边框,下面修改的代码将按照我指定的更新工作表工作

Sub test()
    Dim i As Long, j As Long
    i = 2
    j = 2
    Call BICO(i)
    Call ssp(j)
End Sub

Sub ssp(im)
    Dim wsSSP As Worksheet: Set wsSSP = ThisWorkbook.Sheets(1)
    Dim a1 As String
    Dim a2 As String
    a1 = "A" & im
    a2 = "C" & im

    wsSSP.Range(a1, a2).Borders(xlDiagonalDown).LineStyle = xlNone
    wsSSP.Range(a1, a2).Borders(xlDiagonalUp).LineStyle = xlNone
    With wsSSP.Range(a1, a2).Borders(xlEdgeLeft)
        .LineStyle = xlSolid
        .ColorIndex = xlAutomatic
        .TintAndShade = 0
    End With
    With wsSSP.Range(a1, a2).Borders(xlEdgeBottom)
        .LineStyle = xlSolid
        .ColorIndex = xlAutomatic
        .TintAndShade = 0
    End With
    With wsSSP.Range(a1, a2).Borders(xlEdgeRight)
        .LineStyle = xlSolid
        .ColorIndex = xlAutomatic
        .TintAndShade = 0
    End With
    With wsSSP.Range(a1, a2).Borders(xlInsideVertical)
        .LineStyle = xlSolid
        .ColorIndex = xlAutomatic
        .TintAndShade = 0
    End With
    wsSSP.Cells(2, 1).Value = "Saravanan"
    wsSSP.Cells(2, 2).Value = "Saravanan  S/No Ramsing, Pondichary -60089"
    wsSSP.Cells(2, 3).Value = "9791709616"
End Sub

Sub BICO(jm)
    Dim wsBICO As Worksheet: Set wsBICO = ThisWorkbook.Sheets(2)
    Dim a1 As String
    Dim a2 As String
    a1 = "A" & jm
    a2 = "C" & jm

    wsBICO.Range(a1, a2).Borders(xlDiagonalDown).LineStyle = xlNone
    wsBICO.Range(a1, a2).Borders(xlDiagonalUp).LineStyle = xlNone
    With wsBICO.Range(a1, a2).Borders(xlEdgeLeft)
        .LineStyle = xlSolid
        .ColorIndex = xlAutomatic
        .TintAndShade = 0
    End With
    With wsBICO.Range(a1, a2).Borders(xlEdgeBottom)
        .LineStyle = xlSolid
        .ColorIndex = xlAutomatic
        .TintAndShade = 0
    End With
    With wsBICO.Range(a1, a2).Borders(xlEdgeRight)
        .LineStyle = xlSolid
        .ColorIndex = xlAutomatic
        .TintAndShade = 0
    End With
    With wsBICO.Range(a1, a2).Borders(xlInsideVertical)
        .LineStyle = xlSolid
        .ColorIndex = xlAutomatic
        .TintAndShade = 0
    End With
    wsBICO.Cells(2, 1).Value = "Saravanan"
    wsBICO.Cells(2, 2).Value = "Saravanan  S/No Ramsing, Pondichary -60089"
    wsBICO.Cells(2, 3).Value = "9791709616"
End Sub
更新:

为了使代码更有用,当您为不同的工作表重复代码时,您可以修改Sub以将工作表作为参数,这样您就可以调用同一Sub以影响不同的工作表,请查看以下代码:

Sub test()
    Dim i As Long
    i = 2
    Call DrawBorder(i, ThisWorkbook.Sheets(1))
    Call DrawBorder(i, ThisWorkbook.Sheets(2))
End Sub

Sub DrawBorder(im As Long, ws As Worksheet)
    Dim a1 As String, a2 As String
    a1 = "A" & im
    a2 = "C" & im

    ws.Range(a1, a2).Borders(xlDiagonalDown).LineStyle = xlNone
    ws.Range(a1, a2).Borders(xlDiagonalUp).LineStyle = xlNone

    With wsSSP.Range(a1, a2).Borders(xlEdgeLeft)
        .LineStyle = xlSolid
        .ColorIndex = xlAutomatic
        .TintAndShade = 0
    End With
    With ws.Range(a1, a2).Borders(xlEdgeBottom)
        .LineStyle = xlSolid
        .ColorIndex = xlAutomatic
        .TintAndShade = 0
    End With
    With ws.Range(a1, a2).Borders(xlEdgeRight)
        .LineStyle = xlSolid
        .ColorIndex = xlAutomatic
        .TintAndShade = 0
    End With
    With ws.Range(a1, a2).Borders(xlInsideVertical)
        .LineStyle = xlSolid
        .ColorIndex = xlAutomatic
        .TintAndShade = 0
    End With

    ws.Cells(2, 1).Value = "Saravanan"
    ws.Cells(2, 2).Value = "Saravanan  S/No Ramsing, Pondichary -60089"
    ws.Cells(2, 3).Value = "9791709616"
End Sub

使用宏记录器?看起来您只需要在上面的使用范围周围设置一个全边框。您好,我在第二面有第一个测试函数调用,现在可以逐个调用默认值,但sheet1不是行2不是边框集。但是现在已经设置了第2页第2行的边框。是否使用宏记录器?看起来您只需要在上面的使用范围周围设置一个全边框。您好,我在第二面有第一个测试函数调用,现在可以逐个调用默认值,但sheet1不是行2不是边框集。但是现在设置了工作表2第2行边框。@R.SaravanaKumar我已经更新了我的答案,将工作表用作参数,因此您可以使用同一段代码,只需修改调用即可将更改应用于不同的工作表。希望这有帮助:)@R.SaravanaKumar我已经更新了我的答案,将工作表用作参数,这样您就可以使用同一段代码,通过修改调用将更改应用到不同的工作表上。希望这有帮助:)