Sorry let me explain once again Molly Mam
This macro is made for alert..csv file
Code:Sub STEP29() Dim wb1 As Workbook, wb2 As Workbook, Ws1 As Worksheet, Ws2 As Worksheet Set wb1 = Workbooks.Open("C:\Users\WolfieeeStyle\Desktop\Alert..csv") Set wb2 = ThisWorkbook Set Ws1 = wb1.Worksheets.Item(1): Set Ws2 = wb2.Worksheets.Item(1) Dim arr1() As Variant, arr2() As Variant, arr3() As Variant Let arr1() = Ws1.Range("A1:K" & Ws1.Range("A1").CurrentRegion.Rows.Count & "").Value Let arr2() = Ws2.Range("A1").CurrentRegion.Value ReDim arr3(0 To UBound(arr2(), 1)) Dim Cnt For Cnt = 2 To UBound(arr2(), 1) Dim Lc As Long: Let Lc = Ws2.Cells.Item(Cnt, Ws2.Cells.Columns.Count).End(xlToLeft).Column Let arr3(Cnt - 1) = Ws2.Range("A" & Cnt & ":" & CL(Lc + 1) & Cnt & "").Value Let arr3(Cnt - 1)(1, UBound(arr3(Cnt - 1), 2)) = UBound(arr3(Cnt - 1), 2) - 2 Dim mtchRes As Variant Let mtchRes = Application.Match(arr2(Cnt, 2), Ws1.Range("B1:B" & UBound(arr1(), 1) & ""), 0) If IsError(mtchRes) Then ' a match was not found, so we do not need to remove the 1 2 3 etc... Else ' a match was found, so we need to remove the 1 2 3 etc... Dim Empt As Long For Empt = 3 To UBound(arr3(Cnt - 1), 2) Let arr3(Cnt - 1)(1, Empt) = "" Next Empt End If '3c) Paste out row Let Ws2.Range("A" & Cnt & "").Resize(1, Lc + 1).Value = arr3(Cnt - 1) Next Cnt wb1.Close wb2.Save End Sub Public Function CL(ByVal lclm As Long) As String Do: Let CL = Chr(65 + (((lclm - 1) Mod 26))) & CL: Let lclm = (lclm - (1)) \ 26: Loop While lclm > 0 End Function
But now alert..csv file is replaced with alert.xls
so the macro would be
Code:Sub STEP29() Dim wb1 As Workbook, wb2 As Workbook, Ws1 As Worksheet, Ws2 As Worksheet Set wb1 = Workbooks.Open("C:\Users\WolfieeeStyle\Desktop\Alert.xls") Set wb2 = ThisWorkbook Set Ws1 = wb1.Worksheets.Item(1): Set Ws2 = wb2.Worksheets.Item(1) Dim arr1() As Variant, arr2() As Variant, arr3() As Variant Let arr1() = Ws1.Range("A1:K" & Ws1.Range("A1").CurrentRegion.Rows.Count & "").Value Let arr2() = Ws2.Range("A1").CurrentRegion.Value ReDim arr3(0 To UBound(arr2(), 1)) Dim Cnt For Cnt = 2 To UBound(arr2(), 1) Dim Lc As Long: Let Lc = Ws2.Cells.Item(Cnt, Ws2.Cells.Columns.Count).End(xlToLeft).Column Let arr3(Cnt - 1) = Ws2.Range("A" & Cnt & ":" & CL(Lc + 1) & Cnt & "").Value Let arr3(Cnt - 1)(1, UBound(arr3(Cnt - 1), 2)) = UBound(arr3(Cnt - 1), 2) - 2 Dim mtchRes As Variant Let mtchRes = Application.Match(arr2(Cnt, 2), Ws1.Range("B1:B" & UBound(arr1(), 1) & ""), 0) If IsError(mtchRes) Then ' a match was not found, so we do not need to remove the 1 2 3 etc... Else ' a match was found, so we need to remove the 1 2 3 etc... Dim Empt As Long For Empt = 3 To UBound(arr3(Cnt - 1), 2) Let arr3(Cnt - 1)(1, Empt) = "" Next Empt End If '3c) Paste out row Let Ws2.Range("A" & Cnt & "").Resize(1, Lc + 1).Value = arr3(Cnt - 1) Next Cnt wb1.Close wb2.Save End Sub Public Function CL(ByVal lclm As Long) As String Do: Let CL = Chr(65 + (((lclm - 1) Mod 26))) & CL: Let lclm = (lclm - (1)) \ 26: Loop While lclm > 0 End Function
Any more changes is required in this code then plz let me know Molly Mam




Reply With Quote

Bookmarks