Hi Everyone,
I have a spreadsheet which contains tenant names inside an apartment. What I would like to do is extract data from my rent roll onto a page showing who's lease is expiring in the next 90 days.
Sub run()
Application.ScreenUpdating = False
Dim ws As Worksheet
Dim ws2 As Worksheet
Dim iRows As Long
Set ws = Sheet11 'Data Sheet
Set ws2 = Sheet1 'Results Sheet
ws2.Range("c4:ai1000").Select
Selection.ClearContents
'added count of rows and columns
With ws
iRows = WorksheetFunction.CountA(.Range("C5", .Range("C65536").End(xlUp)))
iCols = WorksheetFunction.CountA(.Range("E3", .Range("IV3").End(xlToLeft)))
End With
For r = 5 To iRows 'added variable here
For c = 5 To iCols 'and here
lrow = ws2.Cells(65535, c - 2).End(xlUp).Offset(1, 0).Address
val1 = ws.Cells(r, c).Value
If IsNumeric(val1) Then
If val1-90 <= formulaR1C1 = "=now()" Then
ws2.Range(lrow).Value = ws.Cells(r, 3).Value
End If
End If
Next c
Next r
Application.ScreenUpdating = True
End Sub
At the end, "val1" has dates within the cells. So it reads- If 'val1'-90 days <= Now() then ws2.range(lrow).value=ws.cells(r, 3).value
Everything works on my sheet except the formula. Any Help?
Bookmarks