LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 129
Default Combine 2 worksheet event change codes

Hi,

I am having problems combining the 2 codes below into 1.

I thought I would be able to just copy the first code and tag it at the
bottom of the second code, but it does not like the line, error on th Range

Range("D" & Rchange, "E" & Rchange, "F" & Rchange).Value = vbNullString
'clears cells for in this row for cols D to F

Any assistance appreciated



Private Sub Worksheet_Change(ByVal Target As Range)
Dim Rchange As Integer
Rchange = Target.Row ' row number selected
If Rchange 3 And Rchange < 5 Then ' make sure only applies to rows
18 to 34
If Target.Address = "$B" & "$" & Rchange Then
'MsgBox "Target address changed :" & Target.Address
Range("D" & Rchange, "E" & Rchange, "F" & Rchange).Value =
vbNullString 'clears cells for in this row for cols D to F

End If
Else
End If
End Sub


Private Sub Worksheet_Change(ByVal Target As Range) 'SAS


Dim rng
Dim r As Long
Dim lc As Long
Dim ans As String
Dim rngDV As Range
If Target.Count 1 Or Target.Column < 3 Then Exit Sub

Me.Unprotect Password:="psswrd"
Set rngDV = Cells.SpecialCells(xlCellTypeAllValidation)
If Intersect(Target, rngDV) Is Nothing Then
Application.EnableEvents = False
Target = ""
Application.EnableEvents = True


Exit Sub
End If


r = Target.Row
lc = Cells(r, Columns.Count).End(xlToLeft).Column + 1
Application.EnableEvents = False
Cells(r, lc) = Target
Application.EnableEvents = True
If Application.CountIf(Range(Cells(r, "d"), Cells(r, "Q")), Target) 1 Then
ans = MsgBox("Duplicated, Continue?", vbYesNo)
If ans = vbNo Then
Cells(r, lc) = ""
End If
Target = ""
End If
If Not Application.Intersect(Target,
Range("C4,C7,C10,C13,C16,C19,C22,C25,C28,C31,C34") ) _
Is Nothing Then
Selection.ClearContents
End If


Me.Protect Password:="psswrd"

End Sub

Thankyou
Winnie
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
combine change event codes J.W. Aldridge Excel Programming 2 January 20th 07 04:42 PM
Linking worksheet event codes Mr. G. Excel Worksheet Functions 7 July 15th 05 06:15 PM


All times are GMT +1. The time now is 11:06 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"