0

I'm wanting to do a subtraction between two numbers, of which they are located in the Columns L and W of the worksheet, I make a for to sweep the rows and make the account about each row, but my result is not coming out correct in val variable, could someone help me? See below my code in vba:

Sub Expense_reports_deadline()

Dim ultimaLinha As Long
Dim val As Long
Dim deadile As String
Dim i As Long

ultimaLinha = Sheet6.Cells(Rows.count, 1).End(xlUp).Row

For i = 6 To ultimaLinha

   val = Cells(i, L).Value - Cells(i, W).Value

    If val <= 30 Then

        MsgBox val
        deadline = "on time"
     
    Else

        MsgBox val
        dedline = "overdue"
        
    End If
Next i
End Sub
BigBen
  • 38,994
  • 6
  • 24
  • 37
  • `"L"` and `"W"`. You need quotes. Also, prefer something other than `val` as a variable; that's shadowing the [`Val`](https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/val-function) function. – BigBen Dec 03 '21 at 17:14

0 Answers0