guitarsweety
07-29-2015, 06:04 AM
I'm using the code below to change the interior cell colors of a cell if Column H is less than Column K. It works great until I have to add another column for an additional inventory item.
Can anyone help me revise this code to maybe select the first column and then do the less than column 3 columns over.14028
Sub macro7()'Inventory
If Environ("UserName") = "dwood" Or Environ("UserName") = "rwagner" Then
Dim rng As Range
For Each rng In Range("H7:H34")
If Cells(rng.Row, "H") < Cells(rng.Row, "K") Then
rng.Interior.Color = RGB(255, 199, 206)
MsgBox "Check Inventory Balance in cell " & Cells(rng.Row, "H").Address(0, 0) & ".", vbExclamation + vbOKOnly + vbApplicationModal, "Insteel Wire Products"
End If
Next rng
If rng Is Nothing Then
MsgBox "All other inventory balances are at a good level", vbInformation + vbOKOnly + vbApplicationModal, "Insteel Wire Products"
End If
Else
MsgBox "Only The Business Unit Assistant can access this function!", vbCritical, "Insteel Wire Products"
End If
Exit Sub
End Sub
Can anyone help me revise this code to maybe select the first column and then do the less than column 3 columns over.14028
Sub macro7()'Inventory
If Environ("UserName") = "dwood" Or Environ("UserName") = "rwagner" Then
Dim rng As Range
For Each rng In Range("H7:H34")
If Cells(rng.Row, "H") < Cells(rng.Row, "K") Then
rng.Interior.Color = RGB(255, 199, 206)
MsgBox "Check Inventory Balance in cell " & Cells(rng.Row, "H").Address(0, 0) & ".", vbExclamation + vbOKOnly + vbApplicationModal, "Insteel Wire Products"
End If
Next rng
If rng Is Nothing Then
MsgBox "All other inventory balances are at a good level", vbInformation + vbOKOnly + vbApplicationModal, "Insteel Wire Products"
End If
Else
MsgBox "Only The Business Unit Assistant can access this function!", vbCritical, "Insteel Wire Products"
End If
Exit Sub
End Sub