Change_Event macro dismiss table1 copy reinstate Table1
Hi Howard,
Am Sat, 28 Nov 2015 03:11:38 -0800 (PST) schrieb L. Howard:
If LCase(ActiveSheet.Name) = "summary" Then GoTo done
I guess the line above causes the error and there are some dots missing.
Why do write the code into a Worksheet_Change event? If Col A get
changed or a value is inserted the macro fires. Also in the Cols B, C
and D.
If always all cells are filled restrict the macro for only column D:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As
Range)
If Intersect(Target, Range("D:D")) Is Nothing _
Or Target.Count 1 Then Exit Sub
If LCase(ActiveSheet.Name) < "summary" And _
LCase(ActiveSheet.Name) < "begin blad" Then
With Application
.EnableEvents = False
.ScreenUpdating = False
End With
On Error GoTo aft_error
Dim aRow As Long
Dim aRng As Range
Dim tRow As Long, i As Long
aRow = Target.Row
Set aRng = Range("A" & aRow).Resize(1, 4)
With Sheets("Summary")
For i = 1 To .ListObjects.Count
.ListObjects(i).Unlist
Next
.Range("A" & Rows.Count).End(xlUp)(2) _
.Resize(1, 4).Value = aRng.Value
'**** reinstate Table1 to Summary sheet *****
tRow = .Cells(.Rows.Count, "A").End(xlUp).Row
.ListObjects.Add(xlSrcRange, .Range("$A$3:$D$" & tRow), , xlYes)
_
.Name = "Table1"
.ListObjects("Table1").TableStyle = "TableStyleLight2"
End With
End If
aft_error:
With Application
.EnableEvents = True
.ScreenUpdating = True
End With
End Sub
Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional
|