vba_hold_report

Sub Hold()

Dim MyBook1 As Workbook
Set MyBook1 = ActiveWorkbook


Workbooks.Open ("\\Cngscapl-spf303\Customer_Care\Doc_Import\Share\AM Team\01 IB - LARA\15 Personal Folder\bOB\Database_Bob.accdb")
Set MyBook2 = ActiveWorkbook
MyBook2.Sheets(2).Copy MyBook1.Sheets("Page1_1")

MyBook1.Sheets("Sheet2").Name = "Holds History"



For z = 4 To Sheets("Page1_1").Range("a65536").End(xlUp).ROW
If Sheets("Page1_1").Cells(z, "o") Like "*day*" Then

Sheets("Page1_1").Cells(z, "q") = Split(Sheets("Page1_1").Cells(z, "o"), " day")

Else

Sheets("Page1_1").Cells(z, "q") = 1

End If
Next z


For x = 4 To Sheets("Page1_1").Range("a65536").End(xlUp).ROW

If Sheets("Page1_1").Cells(x, "L") >= 1 And Sheets("Page1_1").Cells(x, "M") = 0 And Sheets("Page1_1").Cells(x, "q") < 5 And "US" = Left(Sheets("Page1_1").Cells(x, "G"), 2) Then

Sheets("Page1_1").Cells(x, "p") = Sheets("Page1_1").Cells(x, "e") & "," & "DA,"

ElseIf Sheets("Page1_1").Cells(x, "L") = 0 And Sheets("Page1_1").Cells(x, "M") >= 1 And Sheets("Page1_1").Cells(x, "q") < 5 And "US" = Left(Sheets("Page1_1").Cells(x, "G"), 2) Then

Sheets("Page1_1").Cells(x, "p") = Sheets("Page1_1").Cells(x, "e") & "," & ",CS"

ElseIf Sheets("Page1_1").Cells(x, "L") >= 1 And Sheets("Page1_1").Cells(x, "M") >= 1 And Sheets("Page1_1").Cells(x, "q") < 5 And "US" = Left(Sheets("Page1_1").Cells(x, "G"), 2) Then

Sheets("Page1_1").Cells(x, "p") = Sheets("Page1_1").Cells(x, "e") & "," & "DA,CS"

End If

Next x

Sheets.Add
ActiveSheet.Name = "Holds BLs"

k = 2


For Y = 4 To Sheets("Page1_1").Range("P65536").End(xlUp).ROW

If IsError(Application.VLookup(Sheets("Page1_1").Cells(Y, "p"), Sheets("Holds History").Range("A:A"), 1, False)) And Sheets("Page1_1").Cells(Y, "p") <> "" Then

Sheets("Holds BLs").Cells(k, "a") = Sheets("Page1_1").Cells(Y, "p")

k = k + 1

End If


Next Y

For X1 = 1 To Sheets("Holds BLs").Range("a65536").End(xlUp).ROW
Sheets("Holds BLs").Cells(X1, "B") = Split(Sheets("Holds BLs").Cells(X1, "a"), ",")
If Sheets("Holds BLs").Cells(X1, "A") Like "*DA*" Then
Sheets("Holds BLs").Cells(X1, "C") = "DA"
End If
If Sheets("Holds BLs").Cells(X1, "A") Like "*CS*" Then
Sheets("Holds BLs").Cells(X1, "D") = "CS"
End If
Next X1

[b1] = "BL Number"
[c1] = "Usda Hold"
[d1] = "Uscs Hold"
Cells.EntireColumn.AutoFit

ROW1 = MyBook2.Sheets("Sheet2").Range("a65536").End(xlUp).ROW

MyBook2.Sheets("Sheet2").Cells(ROW1 + 1, "A") = Date
MyBook2.Sheets("Sheet2").Cells(ROW1 + 1, "A").Interior.Color = 5296274

For X2 = 2 To MyBook1.Sheets("Holds BLs").Range("a65536").End(xlUp).ROW

MyBook2.Sheets("Sheet2").Cells(ROW1 + 2, "A") = MyBook1.Sheets("Holds BLs").Cells(X2, "A")

ROW1 = ROW1 + 1

Next X2


MyBook2.Save
MyBook2.Close

MsgBox "Done"

End Sub

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值