ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   help in VB for cell values changing in rows & columns w/result in (https://www.excelbanter.com/excel-programming/360793-help-vbulletin-cell-values-changing-rows-columns-w-result.html)

Gale

help in VB for cell values changing in rows & columns w/result in
 
The value in F is either less than 10 or greater than 10. Value is a
variable date in columns D, G & E.

If Col F result is 10 or more, and G2 is = D2, THEN COMPLIANT
If Col F result is 10 or more, and G2 is < D2, THEN NONCOMPLIANT
If Col F result is <10, and E3 is = D3, THEN COMPLIANT
If Col F result is <10, and E3 is < D3, THEN NONCOMPLIANT


Tom Ogilvy

help in VB for cell values changing in rows & columns w/result in
 
Sub AABBCC()
Dim rngF as Range, rngG as Range, rngD as Range
Dim rngD1 as Range, rngE as Range
Dim i as Long
For i = 2 To 202
Set rngF = Cells(i, "F")
Set rngG = Cells(i, "G")
Set rngD = Cells(i, "D")
Set rngD1 = Cells(i + 1, "D")
Set rngE = Cells(i + 1, "E")

If rngF 10 And rngG = rngD Then
res = "COMPLIANT"
ElseIf (rngF 10 And rngG < rngD) Then
res = "NONCOMPLIANT"
ElseIf (rngF < 10 And rngE = rngD1) Then
res = "COMPLIANT"
ElseIf (rngF < 10 And rngE < rngD1) Then
res = "NONCOMPLIANT"
Else
res = "anomaly"
End If
MsgBox "row: " & i & " result: " & res
Next

End Sub


--
Regards,
Tom Ogilvy

"Gale" wrote in message
...
The value in F is either less than 10 or greater than 10. Value is a
variable date in columns D, G & E.

If Col F result is 10 or more, and G2 is = D2, THEN COMPLIANT
If Col F result is 10 or more, and G2 is < D2, THEN NONCOMPLIANT
If Col F result is <10, and E3 is = D3, THEN COMPLIANT
If Col F result is <10, and E3 is < D3, THEN NONCOMPLIANT




Tom Ogilvy

help in VB for cell values changing in rows & columns w/result in
 
Missed the change in criteria

Sub AABBCC()
Dim rngF as Range, rngG as Range, rngD as Range
Dim rngD1 as Range, rngE as Range
Dim i as Long

Set rngG = Cells(2, "G")
Set rngD = Cells(2, "D")
Set rngD1 = Cells(3, "D")
Set rngE = Cells(3, "E")

For i = 4 To 204
Set rngF = Cells(i, "F")

If rngF = 10 And rngG = rngD Then
res = "COMPLIANT"
ElseIf (rngF = 10 And rngG < rngD) Then
res = "NONCOMPLIANT"
ElseIf (rngF < 10 And rngE = rngD1) Then
res = "COMPLIANT"
ElseIf (rngF < 10 And rngE < rngD1) Then
res = "NONCOMPLIANT"
Else
res = "anomaly"
End If
MsgBox "row: " & i & " result: " & res
Next

End Sub

--
Regards,
Tom Ogilvy


"Tom Ogilvy" wrote in message
...
Sub AABBCC()
Dim rngF as Range, rngG as Range, rngD as Range
Dim rngD1 as Range, rngE as Range
Dim i as Long
For i = 2 To 202
Set rngF = Cells(i, "F")
Set rngE = Cells(i + 1, "E")

If rngF 10 And rngG = rngD Then
res = "COMPLIANT"
ElseIf (rngF 10 And rngG < rngD) Then
res = "NONCOMPLIANT"
ElseIf (rngF < 10 And rngE = rngD1) Then
res = "COMPLIANT"
ElseIf (rngF < 10 And rngE < rngD1) Then
res = "NONCOMPLIANT"
Else
res = "anomaly"
End If
MsgBox "row: " & i & " result: " & res
Next

End Sub


--
Regards,
Tom Ogilvy

"Gale" wrote in message
...
The value in F is either less than 10 or greater than 10. Value is a
variable date in columns D, G & E.

If Col F result is 10 or more, and G2 is = D2, THEN COMPLIANT
If Col F result is 10 or more, and G2 is < D2, THEN NONCOMPLIANT
If Col F result is <10, and E3 is = D3, THEN COMPLIANT
If Col F result is <10, and E3 is < D3, THEN NONCOMPLIANT







All times are GMT +1. The time now is 12:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com