nniedzielski
Well-known Member
- Joined
- Jan 8, 2016
- Messages
- 598
- Office Version
- 2019
- Platform
- Windows
Hello All-
I am running a macro that has been working for quite some time now, but for some reason it now has a glitch, the only thing that has been changed is the share drive it has been connecting to was renamed. I has posted the code below, the line in red is where the problem is occurring, there are two files, X & Y, X will activate, however when it comes to Y activating, X stays on the screen and Y never activates.
Any help is always appreciated,
I am running a macro that has been working for quite some time now, but for some reason it now has a glitch, the only thing that has been changed is the share drive it has been connecting to was renamed. I has posted the code below, the line in red is where the problem is occurring, there are two files, X & Y, X will activate, however when it comes to Y activating, X stays on the screen and Y never activates.
Any help is always appreciated,
Code:
Dim thisdate As Date
Dim x As Workbook
Dim y As Workbook
Dim FileY As String
Dim j As Long
Dim i As Long
Dim k As Long
Dim r As Variant
Dim Found As Range
Dim NewPath As String, OldFile As String, NewFile As String
thisdate = Date
FileMonth = Month(thisdate)
thisMonth = MonthName(FileMonth)
FileY = "[URL="file://\\Usbtrwdcnhm5mz1\XPO\DOCK"]\\Usbtrwdcnhm5mz1\XPO\DOCK[/URL] INBOUNDS\ITA/ITA.xls"
Select Case True
Case Len(Dir(FileY)) > 0
Workbooks.Open FileY
Case Len(Dir("J" & Right(FileY, Len(FileY) - 1))) > 1
FileY = "J" & Right(FileY, Len(FileY) - 1)
Workbooks.Open FileY
Case Len(Dir("I" & Right(FileY, Len(FileY) - 1))) > 1
FileY = "J" & Right(FileY, Len(FileY) - 1)
Workbooks.Open FileY
Case Else
End Select
If Not Dir(FileY, vbDirectory) = vbNullString Then
Set x = Workbooks.Open("[URL="file://\\Usbtrwdcnhm5mz1\XPO\DOCK"]\\Usbtrwdcnhm5mz1\XPO\DOCK[/URL] INBOUNDS\2018" & thisMonth & ".xlsx")
Set y = Workbooks.Open(FileY)
Rows("1:4").Delete
Selection.AutoFilter
ActiveSheet.Range("A:D").AutoFilter Field:=4, Criteria1:="<>MTRL - Raw", Criteria2:="<>MTRL - Service"
ActiveSheet.AutoFilter.Range.Offset(1, 0).Rows.SpecialCells(xlCellTypeVisible).Delete (xlShiftUp)
Selection.AutoFilter
Range("E2").Formula = "=VLOOKUP(TRIM(A2),'[!! IB Macro.xlsm]Codes'!$A$1:$B$110,2,FALSE)"
lastRow = Range("D" & Rows.Count).End(xlUp).Row
Range("E2").AutoFill Destination:=Range("E2:E" & lastRow)
Else
MsgBox "ITA File Not Found, Please Run Inbound Trailers Arrived Report and Save as ITA", 48, "File Not Found"
Exit Sub
End If
Dim ColN
ColN = Array(3, 8, 14, 19)
Dim ColR
ColR = Array(2, 7, 13, 18)
x.Activate
Worksheets(Format(Date, "mmmd")).Select
For k = LBound(ColN) To UBound(ColN)
For t = LBound(ColR) To UBound(ColR)
finalrow = Cells(Rows.Count, ColR(t)).End(xlUp).Row
For i = 5 To finalrow
x.Activate
Worksheets(Format(Date, "mmmd")).Select
r = Cells(i, ColN(k)).Value
s = Cells(i, ColR(t)).Value
[COLOR=#FF0000]y.Activate[/COLOR]