我开始变得非常沮丧。有时它工作,有时我只是得到错误ByRef参数类型不匹配。
我也无法理解我的问题,我试图在列中重新命名,交付或不交付行。我的代码如下。
对于混乱的代码视图,很抱歉,有些代码会被删除以供查看
任何帮助都非常适合。
Sub getAM() *在专用小区中过滤AM-Shipment。从EKU获取数据,然后检查出货量是否低谷。
Set dataworksheet = ActiveWorkbook.Worksheets("FR")
Set leveranssheet = ActiveWorkbook.Worksheets("Shipment")
'Clean old data
Lastrow = leveranssheet.Range("b" & Rows.Count).End(xlUp).Row
If Lastrow > 28 Then
leveranssheet.Range(leveranssheet.Cells(29, 1), leveranssheet.Cells(Lastrow, 16)).Clear
End If
'Filter on AM
With Worksheets("ForecastData")
If .FilterMode Then .ShowAllData
.Range("A:K").AutoFilter Field:=1, Criteria1:="AM"
.Range("A:K").AutoFilter Field:=2, Criteria1:="=" & "PD" & "*"
'Filtrera på grupp angiven i ruta:
.Range("A:K").AutoFilter Field:=8, Criteria1:="=" & leveranssheet.Cells(2, 5).Value & "*"
'Cut out columns and place on right position in shipmentsheet.
Lastrow = .Range("a" & Rows.Count).End(xlUp).Row
If Lastrow > 1 Then
'ID, status, description
.Range(.Cells(1, 2).Offset(rowOffset:=1), .Cells(Lastrow, 4)).SpecialCells(xlCellTypeVisible).Copy
leveranssheet.Range("b29").PasteSpecial
Application.CutCopyMode = False
'Grupp
.Range(.Cells(1, 8).Offset(rowOffset:=1), .Cells(Lastrow, 8)).SpecialCells(xlCellTypeVisible).Copy
leveranssheet.Range("e29").PasteSpecial
Application.CutCopyMode = False
'Type of delivery
.Range(.Cells(1, 10).Offset(rowOffset:=1), .Cells(Lastrow, 10)).SpecialCells(xlCellTypeVisible).Copy
leveranssheet.Range("f29").PasteSpecial
Application.CutCopyMode = False
'NExt delivery, Sp, DI
.Range(.Cells(1, 5).Offset(rowOffset:=1), .Cells(Lastrow, 7)).SpecialCells(xlCellTypeVisible).Copy
leveranssheet.Range("g29").PasteSpecial
Application.CutCopyMode = False
'Resp
.Range(.Cells(1, 9).Offset(rowOffset:=1), .Cells(Lastrow, 9)).SpecialCells(xlCellTypeVisible).Copy
leveranssheet.Range("j29").PasteSpecial
Application.CutCopyMode = False
'Ordered by
.Range(.Cells(1, 11).Offset(rowOffset:=1), .Cells(Lastrow, 11)).SpecialCells(xlCellTypeVisible).Copy
leveranssheet.Range("k29").PasteSpecial
Application.CutCopyMode = False
End If
End With
'Hämtar dagens status från EKU_view
With leveranssheet
Lastrow = .Range("b" & Rows.Count).End(xlUp).Row
'Loop trough shipments
For i = 29 To Lastrow
ASMTid = .Cells(i, 2).Value
'find correct datecolumns after shipment
Dim milsten3 As Long
Dim milsten1 As Variant
Dim milsten2 As Variant
Set flik = dataworksheet
leta = leveranssheet.Cells(i, 6).Value
milsten1 = Left(leta, 3)
milsten2 = Right(milsten1, 2)
milsten3 = "MILESTONE_" & milsten2
Debug.Print (milsten3)
'name = AlphaNumericOnly(leta)
Dim statuskolumn As Long
这里我得到了我的byRef错误
leveranskolumn = kolumnNRAM( milsten3 ,flik) Debug.Print(“Leveranskolumn =”& leveranskolumn)
statuskolumn = kolumnNRASMTstatus(milsten3, flik)
Debug.Print ("Statuskolumn= " & statuskolumn)
Dim dagensdatum As Date
Dim dagensstatus As Date
Dim lev As String
Dim stat As String
If leveranskolumn > 0 Then
dagensdatum = dataworksheet.Cells(Rad, leveranskolumn).Value 'Dagens datum för leveransen
leveranssheet.Cells(i, 13).Value = IsWeekend(dagensdatum) 'Dagens datum för leveransen
If leveranssheet.Cells(i, 13).Value<> leveranssheet.Cells(i, 7).Value Then
leveranssheet.Cells(i, 1).Value = "Replanned"
End If
End If
If statuskolumn > 0 Then
dagensstatus = dataworksheet.Cells(Rad, statuskolumn).Value 'Dagens datum för leveransen
leveranssheet.Cells(i, 12).Value = dagensstatus 'Dagens datum för leveransen
End If
End If
lev = leveranssheet.Cells(i, 6)
stat = leveranssheet.Cells(i, 12)
If leveranssheet.Cells(i, 12).Value >= 1 Then
leveranssheet.Cells(i, 1).Value = "Delivered"
Else
leveranssheet.Cells(i, 1).Value = "Not Delivered"
End If
Uppdate,这是不适用我想要的代码行。
If leveranskolumn > 0 Then
dagensdatum = dataworksheet.Cells(Rad, leveranskolumn).Value 'Dagens datum för leveransen
leveranssheet.Cells(i, 13).Value = IsWeekend(dagensdatum) 'Dagens datum för leveransen
End If
If statuskolumn > 0 Then
dagensstatus = dataworksheet.Cells(Rad, statuskolumn).Value 'Dagens datum för leveransen
leveranssheet.Cells(i, 12).Value = dagensstatus
If leveranssheet.Cells(i, 12).Value >= 1 Then
leveranssheet.Cells(i, 1).Value = "Delivered"
ElseIf leveranssheet.Cells(i, 13).Value <> leveranssheet.Cells(i, 7).Value Then
leveranssheet.Cells(i, 1).Value = "Replanned"
Else: leveranssheet.Cells(i, 1).Value = "Not Delivered"
End If
End If
'Dagensdatumförleveransen