Below is the formula for a sample work book having sheet names - sheet1, sheet2, sheet3, sheet4 respectively.
If i change the name of the sheet to depts. say ADM, PRC, HSE; i receive debug msgs.
I believe highlighted places are the reason for the debug msg. Kindly, review and assist me in changing the sheet name.
Regards,
ganeshm
Private Sub Worksheet_Change(ByVal Target As Range)
With ActiveSheet
If Target.Cells.Count = 1 Then
If Target.Column = 5 Then
If InStr("2 5 6 7 8", Target.Row) > 0 Then
Application.EnableEvents = False
'retrieve data
Badgeno = .Range("e2")
foundSh = 0
For sh = 2 To 4
Set found = Sheets("sheet" & sh).Range("b:b").Find(Badgeno, LookIn:=xlValues)
If Not found Is Nothing Then
foundSh = sh
foundRow = found.Row
Exit For
End If
Next sh
.Range("f2") = ""
If foundSh > 0 Then
If Target.Row = 2 Then
For c = 1 To 5
.Cells(c + 4, "e") = Sheets("sheet" & foundSh).Cells(foundRow, c + 2)
Next
Else
For c = 1 To 5
Sheets("sheet" & foundSh).Cells(foundRow, c + 2) = .Cells(c + 4, "e")
Next
End If
Else
.Range("f2") = "BadgeNo. not found"
.Range("e5") = ""
.Range("e6") = ""
.Range("e7") = ""
.Range("e8") = ""
End If
Application.EnableEvents = True
End If
End If
End If
End With
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
End Sub
If i change the name of the sheet to depts. say ADM, PRC, HSE; i receive debug msgs.
I believe highlighted places are the reason for the debug msg. Kindly, review and assist me in changing the sheet name.
Regards,
ganeshm
Private Sub Worksheet_Change(ByVal Target As Range)
With ActiveSheet
If Target.Cells.Count = 1 Then
If Target.Column = 5 Then
If InStr("2 5 6 7 8", Target.Row) > 0 Then
Application.EnableEvents = False
'retrieve data
Badgeno = .Range("e2")
foundSh = 0
For sh = 2 To 4
Set found = Sheets("sheet" & sh).Range("b:b").Find(Badgeno, LookIn:=xlValues)
If Not found Is Nothing Then
foundSh = sh
foundRow = found.Row
Exit For
End If
Next sh
.Range("f2") = ""
If foundSh > 0 Then
If Target.Row = 2 Then
For c = 1 To 5
.Cells(c + 4, "e") = Sheets("sheet" & foundSh).Cells(foundRow, c + 2)
Next
Else
For c = 1 To 5
Sheets("sheet" & foundSh).Cells(foundRow, c + 2) = .Cells(c + 4, "e")
Next
End If
Else
.Range("f2") = "BadgeNo. not found"
.Range("e5") = ""
.Range("e6") = ""
.Range("e7") = ""
.Range("e8") = ""
End If
Application.EnableEvents = True
End If
End If
End If
End With
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
End Sub