I'm having a hard time solving a problem. I've just recently started coding and I would like to create a macro that checks 3 variables (1 for date and 2 for position) without using the Selection function.
What I'm trying to achieve is to have a cell that checks 1 cell with a date (A) to determine if the date is before today and if the cell is not blank. It would either write "Expired" (if the date is before today) or the text in the cell to the left.
It would then move on to the below cells and do this again. Even though this works, it is very slow and I was wondering if there was any other method I could use to speed this up (at 8000 lines this is really not worth it). Maybe use a filter?
Any help is much appreciated!
Dim status As String Dim exp As Date Dim i As Integer Dim n As Integer Dim m As Integer i = 0 n = 1 status = 1 m = 1 Do While status <> "" Cells.Find(What:="A", After:=ActiveCell, LookIn:=xlFormulas _ , LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False, SearchFormat:=False).Activate ActiveCell.Offset(n, 0).Select exp = Selection Cells.Find(What:="B", After:=ActiveCell, LookIn:=xlFormulas _ , LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False, SearchFormat:=False).Activate ActiveCell.Offset(m, 0).Select status = ActiveCell.Offset(i, -1).Value MsgBox (status) If exp <> 0 And exp < Date Then ActiveCell.FormulaR1C1 = "Expired" Else ActiveCell.FormulaR1C1 = status End If i = i - 1 n = n + 1 m = m + 1 Loop EDIT: I think this more or less shows what I would like to do in a simple way. The aim is to only change the Status text when the date is before today. However, there could be additional columns (like Amount) so I would like to avoid static ranges and in case of 25000 rows the selection method is VERRRY slow. I do feel like I've overcomplicated this a bit with the do while.