adityazxcv
01-08-2016, 04:09 AM
I have designed a VBA code for Displaying YES or NO based on Certain Conditions. If data of column C is greater than 0.5 then Displaying NO along with corresponding value of data of Cell in A column . If the data of column C is less than 0.5 then Displaying YES only. The same process for the D column. Example: If C or D column has data 0.6 on fifth cell. Then had Printed NO with its corresponding value in fifth Cell of Column A. If data Contains 0.4 Then Print only YES. I had printed the Output in Single display Box for all data .
Code is Shown:
Sub ArrayLoops1()
Dim arrCMarks(), arrDMarks()
Dim i, j As Integer
Dim otptStr As String
'For Column C
arrCMarks = Range("C2:C1439").Value
For i = LBound(arrCMarks, 1) To UBound(arrCMarks, 1)
If arrCMarks(i, 1) >= 0.5 Then
otptStr = otptStr & "NO(C Column) : " & " Corresponding Data in A" & " " & Range("A" & i + 1).Text & vbCrLf
End If
Next i
' For Column D
arrDMarks = Range("D2:D1439").Value
For j = LBound(arrDMarks, 1) To UBound(arrDMarks, 1)
If arrDMarks(j, 1) >= 0.8 Then
otptStr = otptStr & "NO( D Column) : " & " Corresponding data in A " & " " & Range("A" & j + 1).Text & vbCrLf
End If
Next j
MsgBox otptStr, vbOKOnly, "MSGBOX"
End Sub
Now, I need to modify the code according to this.
If Data of Column C is greater than 0.5. Then Shift to Corresponding cell of Column D. Example: if the data of 5th row in Column C is greater than 0.5. Then move to 5th row of D column (Ignore the first four rows) and test the similar condition (Data being greater than 0.9, display NO otherwise Display YES only) for next 5 rows of Column D (from 5th row of column D to 10th row of Column D). if the condition becomes YES15129, Then move back to 6th row of Column C .
Code is Shown:
Sub ArrayLoops1()
Dim arrCMarks(), arrDMarks()
Dim i, j As Integer
Dim otptStr As String
'For Column C
arrCMarks = Range("C2:C1439").Value
For i = LBound(arrCMarks, 1) To UBound(arrCMarks, 1)
If arrCMarks(i, 1) >= 0.5 Then
otptStr = otptStr & "NO(C Column) : " & " Corresponding Data in A" & " " & Range("A" & i + 1).Text & vbCrLf
End If
Next i
' For Column D
arrDMarks = Range("D2:D1439").Value
For j = LBound(arrDMarks, 1) To UBound(arrDMarks, 1)
If arrDMarks(j, 1) >= 0.8 Then
otptStr = otptStr & "NO( D Column) : " & " Corresponding data in A " & " " & Range("A" & j + 1).Text & vbCrLf
End If
Next j
MsgBox otptStr, vbOKOnly, "MSGBOX"
End Sub
Now, I need to modify the code according to this.
If Data of Column C is greater than 0.5. Then Shift to Corresponding cell of Column D. Example: if the data of 5th row in Column C is greater than 0.5. Then move to 5th row of D column (Ignore the first four rows) and test the similar condition (Data being greater than 0.9, display NO otherwise Display YES only) for next 5 rows of Column D (from 5th row of column D to 10th row of Column D). if the condition becomes YES15129, Then move back to 6th row of Column C .