andrewb90
Well-known Member
- Joined
- Dec 16, 2009
- Messages
- 1,077
I have two worksheet change codes I am trying to run on the same page and I have tried putting them together but get odd results. Here is what I have:
Now both Subs work independently, but I get strange things happening (no error codes)
Any way to properly merge these codes effectively?
Thanks,
Andrew
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'Line Highlighting Tool
'>>>>Left Side<<<<
Range("B11:G36").Interior.Color = xlNone
Set S = Application.Intersect(Range(Target.Address), Range("B11:G36"))
If Not S Is Nothing Then
Range("B" & Target.Row & ":G" & Target.Row).Interior.ColorIndex = 6 'Yellow
End If
Range("B40:G40").Interior.Color = xlNone
Set S = Application.Intersect(Range(Target.Address), Range("B40:G40"))
If Not S Is Nothing Then
Range("B" & Target.Row & ":G" & Target.Row).Interior.ColorIndex = 6 'Yellow
End If
'>>>>Right Side<<<<
Range("H11:M42").Interior.Color = xlNone
Set S = Application.Intersect(Range(Target.Address), Range("H11:M42"))
If Not S Is Nothing Then
Range("H" & Target.Row & ":M" & Target.Row).Interior.ColorIndex = 6 'Yellow
End If
Range("H44:M55").Interior.Color = xlNone
Set S = Application.Intersect(Range(Target.Address), Range("H44:M55"))
If Not S Is Nothing Then
Range("H" & Target.Row & ":M" & Target.Row).Interior.ColorIndex = 6 'Yellow
End If
'Name Requirement Code
If Target.Address(False, False) = "H7" And Len(Target.Value) >= 4 And Len(Target.Value) <= 30 Then
MsgBox "Hello " & Target.Value & ". You may now complete the Daily Sales Report." & vbNewLine & "Have a nice day."
Rows("8:55").Hidden = False
Rows("56:80").Hidden = True
ActiveSheet.Shapes("Papa").Visible = False
Range("H7").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
Selection.Borders(xlEdgeTop).LineStyle = xlNone
Selection.Borders(xlEdgeBottom).LineStyle = xlNone
Selection.Borders(xlEdgeRight).LineStyle = xlNone
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
Else
MsgBox "You MUST have a name typed in!!! Please tell me who you are.", vbExclamation
Rows("8:55").Hidden = True
Rows("56:80").Hidden = False
ActiveSheet.Shapes("Papa").Visible = True
Range("H7").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
Selection.Borders(xlEdgeTop).LineStyle = xlNone
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ThemeColor = 2
.TintAndShade = 0
.Weight = xlMedium
End With
Selection.Borders(xlEdgeRight).LineStyle = xlNone
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
Exit Sub
End If
End Sub
Now both Subs work independently, but I get strange things happening (no error codes)
Any way to properly merge these codes effectively?
Thanks,
Andrew