Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Sub Worksheet_Change(ByVal Target As Range)
- Dim rngToCheck As Range
- Dim NumA As Variant, NumB As Variant
- Dim i As Long
- On Error GoTo Whoa
- '~~> Set the relevant range
- Set rngToCheck = Union(Range("G12:G42"), Range("J12:J42"))
- Application.EnableEvents = False
- If Not Intersect(Target, rngToCheck) Is Nothing Then
- For i = 12 To 42 Step 2 '<~~ Loop through only even rows
- NumA = Range("G" & i).Value
- NumB = Range("J" & i).Value
- If IsNumeric(NumA) And IsNumeric(NumB) And NumB <> 0 Then
- If ((NumB - NumA) / NumA) * 100 < 50 Then
- MsgBox "The Glass U-value and Total System U-value appear very similar. Please check the input values for accuracy!"
- Exit For
- End If
- End If
- Next i
- End If
- Letscontinue:
- Application.EnableEvents = True
- Exit Sub
- Whoa:
- MsgBox Err.Description
- Resume Letscontinue
- End Sub
- Private Sub Worksheet_Change(ByVal Target As Range)
- If Target.Value = vbNullString Then Exit Sub
- Dim cell As Range
- On Error GoTo ws_exit
- Application.EnableEvents = False
- With Target
- If .Column = 3 Then
- With .EntireColumn
- Set cell = .Find(What:=Target.Value, AFter:=.Cells(1, 1))
- If cell.Address = Target.Address Then
- Set cell = .FindNext()
- End If
- If Not cell.Address = Target.Address Then
- MsgBox "This Glazing Reference already exists. Please ensure you have a unique reference identifier less than 20 characters in length", vbOKOnly
- End If
- End With
- End If
- End With
- ws_exit:
- Application.EnableEvents = True
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement