Dont allow blank

N

nowfal

Mr.Ron sorry to distrub you, i have tried your latest reply, but faile
again. please look into the matter, i wanted both the code in one shee
, is there any possibility to combine these two code into one.
First code as :
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("C2:C2")) Is Nothing Then Exit Sub
If Range("C2:C2") > 0 Then CUSTOMER
End Sub

Second code as you given earlier there is a slight change in the Ro
number
it is like this:

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Cells(Target.Row, 2) _
.Range("J2,K2,L2"), Target) Is Nothing Then
If Cells(Target.Row, "I") = "" Then
MsgBox " sorry the I column is empty"
Application.EnableEvents = False
Target.Value = ""
Application.EnableEvents = True
End If
End If
End Sub

with regards
nowfa
 
R

Ron de Bruin

Yesterday I posted this example for two ranges

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Range("A1"), Target) Is Nothing Then
MsgBox "You have changed A1"
End If

If Not Application.Intersect(Cells(Target.Row, 1) _
.Range("J1,K1,L1"), Target) Is Nothing Then
If Cells(Target.Row, "I") = "" Then
MsgBox " sorry the I column is empty"
Application.EnableEvents = False
Target.Value = ""
Application.EnableEvents = True
End If
End If
End Sub


Change it to this

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Range("C2"), Target) Is Nothing Then
If IsNumeric(Target.Value) And Target.Value > 0 Then
MsgBox "Run the CUSTOMER macro"
End If
End If

If Not Application.Intersect(Cells(Target.Row, 1) _
.Range("J1,K1,L1"), Target) Is Nothing Then
If Cells(Target.Row, "I") = "" Then
MsgBox " sorry the I column is empty"
Application.EnableEvents = False
Target.Value = ""
Application.EnableEvents = True
End If
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top