Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- https://excel-egy.com/forum/t3807
- ---------------------------------
- Private Sub Worksheet_Change(ByVal Target As Range)
- Dim x, sh As Worksheet, c As Range, m As Long
- Set sh = ThisWorkbook.Worksheets("names_boy_data3")
- If Not Application.Intersect(Target, Columns("A:A")) Is Nothing Then
- Application.EnableEvents = False
- For Each c In Target.Cells
- If Application.WorksheetFunction.CountIf(Range("A11:A3000"), c.Value) > 1 Then MsgBox "Student Is Already There", 64: GoTo Skipper
- x = Application.Match(c.Value, sh.Columns(2), 0)
- If Not IsError(x) Then
- If sh.Range("D" & x).Value = "" Then
- If Range("A2311").Value = "" Then m = 2311 Else m = Cells(Rows.Count, 1).End(xlUp).Row + 1
- Range("A" & m).Value = c.Value
- Range("C" & m).Resize(1, 3).Value = sh.Range("C" & x).Resize(1, 3).Value
- MsgBox "Student Moved As There Is No National ID", 64
- c.Value = ""
- Else
- Range("C" & c.Row).Resize(1, 3).Value = sh.Range("C" & x).Resize(1, 3).Value
- End If
- Else
- Skipper:
- Range("A" & c.Row).Resize(1, 5).Value = ""
- End If
- Next c
- Application.EnableEvents = True
- End If
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement