Hi …
Blank row problem ….
This problem is because
_ I use all UsedRange … This includes
empty column A and empty column L
If column L = “”
If arrL(Cnt, 1) = “” __ is True
If column A = “”
If ____ (Nah - arrA(Cnt, 1)) >= 150 __ is True
So
If arrL(Cnt, 1) = "" And (Nah - arrA(Cnt, 1)) >= 150
is __ = True __ and __ True
So Then Interior Color is made to be vbYellow
This is the problem. You do not want that…
How about,
If column A is “” then Do Nothing
Now I think all is OKCode:Option Explicit Sub ChkChqe() Dim Ws1 As Worksheet Set Ws1 = ThisWorkbook.Worksheets.Item(1) Dim rngA As Range: Set rngA = Ws1.Range("A1:A" & Ws1.UsedRange.Rows.Count & "") Dim rngL As Range: Set rngL = Ws1.Range("L1:L" & Ws1.UsedRange.Rows.Count & "") Dim arrA() As Variant, arrL() As Variant Let arrA() = rngA.Value2: Let arrL() = rngL.Value2 Dim Nah As Long: Let Nah = Now Dim Cnt As Long For Cnt = 3 To Ws1.UsedRange.Rows.Count If arrA(Cnt, 1) = "" Then ' Do nothing Else If arrL(Cnt, 1) = "" And (Nah - arrA(Cnt, 1)) >= 150 Then rngA.Item(Cnt).Interior.Color = vbYellow End If Next Cnt End Sub
Before:
_____ Workbook: Cheque Book Register 11Feb.xls ( Using Excel 2007 32 bit )
Worksheet: Cheques
Row\Col A B C D E F G H I J K L M 74 10.02.2019 072499 19,500.00 Not Entered 75 10.02.2019 072500 Not Entered 76 01.01.2019 072501 2,000.00 01.01.2019 Cleared 01.01.2019 Not Entered 77 10.02.2019 072502 2,000.00 10.02.2019 Cleared 10.02.2019 Not Entered 78 10.09.2018 2,000.00 10.09.2018 Cleared 15.09.2018 Not Entered 79 10.09.2018 2,000.00 31.12.2018 Not Entered 80 Not Entered
After running routine, Sub ChkChqe()
_____ Workbook: Cheque Book Register 11Feb.xls ( Using Excel 2007 32 bit )
Worksheet: Cheques
Row\Col A B C D E F G H I J K L M 75 10.02.2019 072500 Not Entered 76 01.01.2019 072501 2,000.00 01.01.2019 Cleared 01.01.2019 Not Entered 77 10.02.2019 072502 2,000.00 10.02.2019 Cleared 10.02.2019 Not Entered 78 10.09.2018 2,000.00 10.09.2018 Cleared 15.09.2018 Not Entered 79 10.09.2018 2,000.00 31.12.2018 Not Entered 80 Not Entered
Alan




Reply With Quote

Bookmarks