宏已停止工作

时间:2016-08-12 12:35:13

标签: excel vba excel-vba

我的妻子在工作中有一张已停止工作的电子表格。您可以将数据输入一个易于使用的易用工作表中的一个选项卡,然后按一个按钮,数据将传输到另一个工作表上的表格中。输入选项卡被称为" NCR报告"并且表格标签被称为" PM2"下面是宏。知道它为什么停止工作了吗?

Sub Button111_Click()
Dim a As Date
Dim Counter As Integer
Dim Filled As Boolean
Dim ParamOut As String
Dim i As Integer
Dim Reels As String


MsgBox ("Wait...")



'Identify 1st empty row
Counter = 3
While Filled = False
    Counter = Counter + 1
    a = Worksheets("PM 2").Cells(Counter, 1).Value
    If a = 0 Then
        Filled = True
        Else: Filled = False
    End If

Wend

'Shift
 Worksheets("PM2").Cells(Counter, 2).Value = Worksheets("NCR Report").Cells(2, 7).Value

'Production date
 Worksheets("PM2").Cells(Counter, 1).Value = Worksheets("NCR Report").Cells(3, 7).Value

 'Article number
 Worksheets("PM2").Cells(Counter, 4).Value = Worksheets("NCR Report").Cells(4, 7).Value

 'Total weight
  Worksheets("PM2").Cells(Counter, 5).Value = Worksheets("NCR Report").Cells(16, 8).Value

'Parameter out, build the string
ParamOut = ""
For i = 21 To 24
    If Worksheets("NCR Report").Cells(i, 2).Text <> "" Then

        ParamOut = ParamOut & " " & Worksheets("NCR Report").Cells(i, 2).Text & " " & Worksheets("NCR Report").Cells(i, 5).Text & " " & Worksheets("NCR Report").Cells(i, 9).Text & " " & Worksheets("NCR Report").Cells(i, 10).Text
    End If
Next i

Worksheets("PM2").Cells(Counter, 6).Value = ParamOut

'Adjustements
 Worksheets("PM2").Cells(Counter, 7).Value = Worksheets("NCR Report").Cells(29, 2).Value

'Reel number
Reels = ""
Reels = Worksheets("NCR Report").Cells(10, 2).Text


    For i = 11 To 15
     If Worksheets("NCR Report").Cells(i, 2).Value = 0 Then
          Else: Reels = Reels & " / " & Worksheets("NCR Report").Cells(i, 2).Text
        End If
    Next i

Worksheets("PM2").Cells(Counter, 3).Value = Reels

MsgBox ("NCR has been successfully added to the spreadsheet." & vbCrLf & "Don't forget to save this file before quitting and also to block the reels on PLAIN.")


End Sub

0 个答案:

没有答案