VBA with condition

Abhishekghorpade

Board Regular
Joined
Oct 3, 2018
Messages
71
Hi,

Could you please help with VBA code for below condition

If the date in Column “I” is between 01/01/2017 to 12/31/2017 and Column “H” is >=0.50 Column A should display as A else D
 

offthelip

Well-known Member
Joined
Dec 23, 2017
Messages
1,032
Office Version
2010
Platform
Windows
You can do it with an equation:
=IF(AND(YEAR(I1)=2017,H1>=0.5),"A","D")
 
Last edited:

offthelip

Well-known Member
Joined
Dec 23, 2017
Messages
1,032
Office Version
2010
Platform
Windows
If you want to do it using VBA then this will do it for you:
Code:
Sub test()
lastrow = Cells(Rows.Count, "I").End(xlUp).Row
inarr = Range(Cells(1, 8), Cells(lastrow, 9))
For i = 1 To lastrow
 Yr = Year(inarr(i, 2))
 If Yr = "2017" And inarr(i, 1) >= 0.5 Then
  Cells(i, 1) = "A"
 Else
  Cells(i, 1) = "D"
 End If
Next i
 
End Sub
 

Forum statistics

Threads
1,085,229
Messages
5,382,457
Members
401,788
Latest member
zenattitude

Some videos you may like

This Week's Hot Topics

Top