Dear VBA Experts
I have written a code for equal distribution of Budget Data based on condition.

The user will enter annual budget number in Column K (highlighted in Green) and based on condition in Column N (highlighted in Yellow), the data will be divided by 12 and it need to be equally distributed from Colum P to Column AA. The condition for distribution is ‘Y’ (Yes)/ ‘N’ (No).

[Sub BudDist()
Dim myCell As Range
Dim Data As Long
Dim lr As Long
Dim a

lr = Cells(Rows.Count, 11).End(xlUp).Row
For Each myCell In Range("K39:K" & lr)
If UCase(myCel.Offset(, 3).Value) = "Y" Then
Data = myCell.Value / 12
a = myCell.Row
Range("P" & a & ":AA" & a).Value = Data

Next myCell
End Sub]



Error.jpg


Please help me fix the error. The screenshot of the error is attached.

Thanks,
Nisha