0

我的目标是从工作表 1“B5”开始的单元格中复制值并将其粘贴到工作表 2“C11”以后,代码无法正常工作

Sub SCMPROCUREMENT()

' SUPPLY CHAIN MANAGEMENT PROCUREMENT


Worksheets("Sheet1").Select


Range("B5:B100000").Select

finalrow = Cells(Rows.Count, 2).End(xlUp).Row

For x = 5 To finalrow

If Worksheets("sheet1").Cells(x, 2).Font.Bold = False Then

Worksheets("sheet1").Select

Cells(x, 2).Select

Selection.Copy

ThisWorkbook.Worksheets("Sheet2").Range("C11").Select


ActiveSheet.Paste


End If
Next x

End Sub
4

2 回答 2

1

a)您的ThisWorkbook.Worksheets("Sheet2").Range("C11")不能那样工作

b)您需要第二个列表的计数器,否则您将继续覆盖 C11

Sub SCMPROCUREMENT()

    ' SUPPLY CHAIN MANAGEMENT PROCUREMENT

    Dim count As Integer

    For x = 5 To Worksheets("Sheet1").Cells(Rows.count, 2).End(xlUp).Row

        If Worksheets("Sheet1").Cells(x, 2).Font.Bold = False Then

            Worksheets("Sheet1").Cells(x, 2).Copy

            Worksheets("Sheet2").Cells(11 + count, 3).Select
            ActiveSheet.Paste

            count = count + 1

        End If
    Next x

End Sub
于 2013-01-26T22:23:51.360 回答
0
Sub SCMPROCUREMENT()

    ' SUPPLY CHAIN MANAGEMENT PROCUREMENT

    Application.ScreenUpdating = False

    Dim count As Integer

    With Worksheets("Sheet1")

        For x = 5 To .Cells(Rows.count, 2).End(xlUp).Row

            If .Cells(x, 2).Font.Bold = False Then

                .Cells(x, 2).Copy Worksheets("Sheet2").Cells(11 + count, 3)
                count = count + 1
            End If
        Next x

    End With

    Application.ScreenUpdating = True

End Sub
于 2013-01-27T11:09:49.553 回答