zendog1960
Active Member
- Joined
- Sep 27, 2003
- Messages
- 459
- Office Version
- 2019
- Platform
- Windows
Hello folks,
I am getting a "run time error 1004 application defined or object defined" error. I am adding the code below. I would appreciate if someone could look the code over and let me know if they can find out why I am getting this.
First things first: in the Range D2, I have that cell formatted for a date. Range I1 is just a name cell.
It worked for a while but I cannot figure our what has changed
If I comment out that error line, the error moves down to the Case Else line. It's like it isn't doing the select case statement correctly.
I am getting a "run time error 1004 application defined or object defined" error. I am adding the code below. I would appreciate if someone could look the code over and let me know if they can find out why I am getting this.
First things first: in the Range D2, I have that cell formatted for a date. Range I1 is just a name cell.
It worked for a while but I cannot figure our what has changed
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Set Target = Range("D2")
If Target = "" Then Exit Sub
On Error GoTo Badname
ActiveSheet.Name = Format(Target, "mmm-dd-yy")
GoTo EmpName
ActiveWorkbook.Save
Range("D2").Activate
Exit Sub
Badname:
MsgBox "Please revise the entry in D2." & Chr(13) _
& "It appears to contain one or more " & Chr(13) _
& "illegal characters." & Chr(13)
EmpName:
Set Target = Range("I1")
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("I1")) Is Nothing Then
Select Case Target.Value
Case Is = ""
Target.Value = "Enter Your Name Here"
Target.Font.ColorIndex = 15
Case Is = "Enter Your Name Here"
Target.Font.ColorIndex = 15 <----- This is the line that is triggering the error
Case Else
Target.Font.ColorIndex = 1
End Select
End If
End Sub
If I comment out that error line, the error moves down to the Case Else line. It's like it isn't doing the select case statement correctly.
Last edited: