Hi, looking for some help with this. I have the following code in my worksheet, which is supposed to pop-up a message when C19 has the value "BLUE"
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$C$19" And Target.Value = "BLUE" Then
MsgBox "Please ensure that you meant to select BLUE"
End If
End Sub
It works fine, however, it seems to be conflicting with a macro I have recorded that clears data in various cells. The macro code is as follows:
Sub ClearData()
Dim msgPrompt As String, msgTitle As String
Dim msgButtons As Integer, msgResult As Integer
msgPrompt = "Are you sure you want to clear all data?"
msgButtons = vbYesNo + vbQuestion + vbDefaultButton1
msgTitle = "Clear Data?"
msgResult = MsgBox(msgPrompt, msgButtons, msgTitle)
Select Case msgResult
Case vbYes
Sheets("Data Input").Select
With Application
.Calculation = xlManual
.MaxChange = 0.001
End With
ActiveWorkbook.PrecisionAsDisplayed = False
Range("C5:R8").Select
Selection.ClearContents
Range("C12:R34").Select
Selection.ClearContents
Range("C54:R55").Select
Selection.ClearContents
Range("C58:R58").Select
Selection.ClearContents
With Application
.Calculation = xlAutomatic
.MaxChange = 0.001
End With
ActiveWorkbook.PrecisionAsDisplayed = False
Case vbNo
Exit Sub
End Select
End Sub
The error I receive when I run this macro is "Run-time error '13': Type Mismatch".
Can someone help me solve this problem?
Thank you kindly!
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$C$19" And Target.Value = "BLUE" Then
MsgBox "Please ensure that you meant to select BLUE"
End If
End Sub
It works fine, however, it seems to be conflicting with a macro I have recorded that clears data in various cells. The macro code is as follows:
Sub ClearData()
Dim msgPrompt As String, msgTitle As String
Dim msgButtons As Integer, msgResult As Integer
msgPrompt = "Are you sure you want to clear all data?"
msgButtons = vbYesNo + vbQuestion + vbDefaultButton1
msgTitle = "Clear Data?"
msgResult = MsgBox(msgPrompt, msgButtons, msgTitle)
Select Case msgResult
Case vbYes
Sheets("Data Input").Select
With Application
.Calculation = xlManual
.MaxChange = 0.001
End With
ActiveWorkbook.PrecisionAsDisplayed = False
Range("C5:R8").Select
Selection.ClearContents
Range("C12:R34").Select
Selection.ClearContents
Range("C54:R55").Select
Selection.ClearContents
Range("C58:R58").Select
Selection.ClearContents
With Application
.Calculation = xlAutomatic
.MaxChange = 0.001
End With
ActiveWorkbook.PrecisionAsDisplayed = False
Case vbNo
Exit Sub
End Select
End Sub
The error I receive when I run this macro is "Run-time error '13': Type Mismatch".
Can someone help me solve this problem?
Thank you kindly!