Re: convert formula to VBA code
This is perfect. Thank you.
Re: convert formula to VBA code
This is perfect. Thank you.
Hi guys,
I'm currently have this formula to populate the cells according to date. I would like to convert the formula to VBA.
=IF(AND(C$1>=INT($O7),C$1<=INT($P7)),"1.1","")& IF(AND(C$1>=INT($Q7),C$1<=INT($R7)),"1.2","")&IF(AND(C$1>=INT($S7),C$1<=INT($T7)),"1.3","")
I try to write some codes, but don't know how to allow the codes to read until the end. I also need to insert value ("1.1") under each date that meets the requirement.
Private Sub CommandButton1_Click()
Dim date1 As Long, date2 As Long, date3 As Long, result As String
date1 = Range("O7").Value
date2 = Range("P7").Value
date3 = Range("C1").Value
If score3 >= score1 And score3 <= score2 Then
result = "1.1"
Else
result = "x"
End If
Range("C2").Value = result
End Sub
Display More
I need the VBA to continue read through the whole row and compare with Start/End dates. If the dates in row are within Start/End dates, then insert value "1.1".
I have attached the file to show what i want to do.
forum.ozgrid.com/index.php?attachment/68928/
Thank you.