Code:Sub STEP8() Dim Wb1 As Workbook, Wb2 As Workbook Dim Ws1 As Worksheet, Ws2 As Worksheet Set Wb1 = Workbooks.Open("C:\Users\WolfieeeStyle\Desktop\1.xls") Set Wb2 = Workbooks.Open("C:\Users\WolfieeeStyle\Desktop\Alert..csv") Set Ws1 = Wb1.Worksheets.Item(1) Set Ws2 = Wb2.Worksheets.Item(1) Dim Rg1 As Range, RngSrchIn As Range Set Rg1 = Ws1.Cells.Item(1, 1).CurrentRegion Dim Lr2 As Long: Let Lr2 = Ws2.Range("B" & Ws1.Rows.Count & "").End(xlUp).Row Set RngSrchIn = Ws2.Range("B1:B" & Lr2 & "") Rem 2 Dim Cnt For Cnt = 2 To Rg1.Rows.Count Dim cRng As Range Set cRng = RngSrchIn.Find(What:=Ws1.Cells.Item(Cnt, 9), LookIn:=xlValues, Lookat:=xlWhole, searchorder:=xlByRows, Searchdirection:=xlNext, MatchCase:=True) If Not cRng Is Nothing And Not cRng.Value = "" Then If Ws1.Cells(Cnt, 8) > Ws1.Cells(Cnt, 4) Then Let cRng.Offset(, 2).Value = "<" Let cRng.Offset(, 3).Value = Ws1.Cells(Cnt, 11) ElseIf Ws1.Cells(Cnt, 8) < Ws1.Cells(Cnt, 4) Then Let cRng.Offset(, 2).Value = ">" Let cRng.Offset(, 3).Value = Ws1.Cells(Cnt, 11) Else End If Else End If Next Cnt End Sub
I am getting error with this line
If Not cRng Is Nothing And Not cRng.Value = "" Then
error msg =Object variable or with block variable not set




Reply With Quote

Bookmarks