Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
combine change event codes | Excel Programming | |||
Linking worksheet event codes | Excel Worksheet Functions |