Worksheet_Change_Code Problem

jim may

Well-known Member
Joined
Jul 4, 2004
Messages
7,486
Nothing seems to work properly with this code... Any ideas? TIA, Jim

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("B12:I15")) Is Nothing Then
    Select Case Target.Value
        Case Application.WorksheetFunction.IsText(Target)
            MsgBox "You have text"
            'allow formatting
        Case Is = ""
            MsgBox "You have a blank"
            'disallow formatting
        Case IsNumeric(Target)
            MsgBox "You have a number"
            'not sure
        Case Else
     End Select
End If
End Sub
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Try this

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("B12:I15")) Is Nothing Then
    Select Case True
        Case Application.WorksheetFunction.IsText(Target)
            MsgBox "You have text"
            'allow formatting
        Case Is = Target.Value = ""
            MsgBox "You have a blank"
            'disallow formatting
        Case IsNumeric(Target)
            MsgBox "You have a number"
            'not sure
        Case Else
     End Select
End If
End Sub
 
Upvote 0
Try;
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("B12:I15")) Is Nothing Then
        Select Case [B][COLOR="Red"]True[/COLOR][/B]
            Case Application.WorksheetFunction.IsText(Target)
                MsgBox "You have text"
                'allow formatting
            Case [B][COLOR="red"]Len(Target) = 0[/COLOR][/B]
                MsgBox "You have a blank"
                'disallow formatting
            Case IsNumeric(Target)
                MsgBox "You have a number"
                'not sure
            Case Else
         End Select
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,534
Messages
6,179,390
Members
452,909
Latest member
VickiS

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top