B
brunces
Friends,
Please, anybody knows how to make these two VB codes work together?
When I put them together in the same "sheet code page" in VBA, th
second one doesn't work. Why?
*** Code 1 ***
Private Sub Worksheet_Change(ByVal Target As Range)
* * On Error GoTo QuitCode
* * If Intersect(Target, Range("c1:c15")) Is Nothing Then
* * * * Exit Sub
* * ElseIf Target.Value <>*"" And Target.Offset(0, -1).Value = "" Then
* * * * MsgBox "You haven't typed the name of the client yet."
* * * * Target.Offset(0, -1).Activate
End If
QuitCode:
End Sub
*** Code 2 ***
Private Sub Worksheet_Change(ByVal Target As Range)
* * On Error GoTo QuitCode
* * If Intersect(Target, Range("c1:c15")) Is Nothing Then
* * * * Exit Sub
* * Else:
* * * * varSave = MsgBox("Do you want to save this document now?"
vbYesNo)
* * * * If varSave = vbNo Then GoTo QuitCode
* * * * ActiveWorkbook.Save
* * End If
QuitCode:
End Sub
**************
I tried to unite them like this... But it also didn't work, the text
become red.
*** Code 3 ***
Private Sub Worksheet_Change(ByVal Target As Range)
* * On Error GoTo QuitCode
* * If Intersect(Target, Range("a1:c15")) Is Nothing Then
* * * * Exit Sub
* * ElseIf Target.Value <>*"" And Target.Offset(0, -1).Value = "" Then
* * * * MsgBox "You haven't typed the name of the client yet."
* * * * Target.Offset(0, -1).Activate
* * Else:
* * * * varSave = MsgBox("Do you want to save this document now?"
vbYesNo)
* * * * If varSave = vbNo Then GoTo QuitCode
* * * * ActiveWorkbook.Save
* * End If
QuitCode:
End Sub
**************
If anyone could tell me how make them work, I appreciate it.
Thanks a lot.
Hugz,
Brun
Please, anybody knows how to make these two VB codes work together?
When I put them together in the same "sheet code page" in VBA, th
second one doesn't work. Why?
*** Code 1 ***
Private Sub Worksheet_Change(ByVal Target As Range)
* * On Error GoTo QuitCode
* * If Intersect(Target, Range("c1:c15")) Is Nothing Then
* * * * Exit Sub
* * ElseIf Target.Value <>*"" And Target.Offset(0, -1).Value = "" Then
* * * * MsgBox "You haven't typed the name of the client yet."
* * * * Target.Offset(0, -1).Activate
End If
QuitCode:
End Sub
*** Code 2 ***
Private Sub Worksheet_Change(ByVal Target As Range)
* * On Error GoTo QuitCode
* * If Intersect(Target, Range("c1:c15")) Is Nothing Then
* * * * Exit Sub
* * Else:
* * * * varSave = MsgBox("Do you want to save this document now?"
vbYesNo)
* * * * If varSave = vbNo Then GoTo QuitCode
* * * * ActiveWorkbook.Save
* * End If
QuitCode:
End Sub
**************
I tried to unite them like this... But it also didn't work, the text
become red.
*** Code 3 ***
Private Sub Worksheet_Change(ByVal Target As Range)
* * On Error GoTo QuitCode
* * If Intersect(Target, Range("a1:c15")) Is Nothing Then
* * * * Exit Sub
* * ElseIf Target.Value <>*"" And Target.Offset(0, -1).Value = "" Then
* * * * MsgBox "You haven't typed the name of the client yet."
* * * * Target.Offset(0, -1).Activate
* * Else:
* * * * varSave = MsgBox("Do you want to save this document now?"
vbYesNo)
* * * * If varSave = vbNo Then GoTo QuitCode
* * * * ActiveWorkbook.Save
* * End If
QuitCode:
End Sub
**************
If anyone could tell me how make them work, I appreciate it.

Thanks a lot.
Hugz,
Brun