Hi - looking for some help again. I have the following coding that I have tried in both the Sheet code and as a module at different times.
Sub CopyEmployed()
Sheets("Employment").Select
Range("A3:L200").Select
Selection.ClearContents
Range("D4").Select
Sheets("Act1").Select
- And there will be more here when I can get this first part working-
When I step through this works up to "Selection.ClearContents" but then ignores the next two lines
Range("D4").Select
Sheets("Act1").Select
and goes straight to the Private Sub coding below that I am using to change the sheet tab names (This is in the ThisWorkbook section and works perfectly)
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Dim LinkedCells As Range
Dim ArrayOfMatchingSheets As Variant
Dim i As Long
Set LinkedCells = Sheets("Menu").Range("E8:E22")
ArrayOfMatchingSheets = Array(Sheet8, Sheet9, Sheet10, Sheet11, Sheet12, Sheet13, Sheet14, Sheet15, Sheet16, Sheet17, Sheet18, Sheet19, Sheet20, Sheet21, Sheet22)
If Sh.Name = LinkedCells.Parent.Name Then
If Not Application.Intersect(LinkedCells, Target) Is Nothing Then
For i = 0 To 14
On Error Resume Next
ArrayOfMatchingSheets(i).Name = CStr(LinkedCells.Cells(1, 1).Offset(i, 0).Value)
If ArrayOfMatchingSheets(i).Name <> CStr(LinkedCells.Cells(1, 1).Offset(i, 0).Value) Then Beep
On Error GoTo 0
Next i
End If
End If
End Sub
I can continue to step through this until it eventually returns to
Range("D4").Select
Sheets("Act1").Select
It may then run the remainder of the coding but what I have tried so far produces more Runtime and type mismatch errors which I will post after I can fix this.
Bottom line is I dont want the change sheet tab code run - I need the remainder of the Sub CopyEmployed() to run.
Any ideas please?
Sub CopyEmployed()
Sheets("Employment").Select
Range("A3:L200").Select
Selection.ClearContents
Range("D4").Select
Sheets("Act1").Select
- And there will be more here when I can get this first part working-
When I step through this works up to "Selection.ClearContents" but then ignores the next two lines
Range("D4").Select
Sheets("Act1").Select
and goes straight to the Private Sub coding below that I am using to change the sheet tab names (This is in the ThisWorkbook section and works perfectly)
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Dim LinkedCells As Range
Dim ArrayOfMatchingSheets As Variant
Dim i As Long
Set LinkedCells = Sheets("Menu").Range("E8:E22")
ArrayOfMatchingSheets = Array(Sheet8, Sheet9, Sheet10, Sheet11, Sheet12, Sheet13, Sheet14, Sheet15, Sheet16, Sheet17, Sheet18, Sheet19, Sheet20, Sheet21, Sheet22)
If Sh.Name = LinkedCells.Parent.Name Then
If Not Application.Intersect(LinkedCells, Target) Is Nothing Then
For i = 0 To 14
On Error Resume Next
ArrayOfMatchingSheets(i).Name = CStr(LinkedCells.Cells(1, 1).Offset(i, 0).Value)
If ArrayOfMatchingSheets(i).Name <> CStr(LinkedCells.Cells(1, 1).Offset(i, 0).Value) Then Beep
On Error GoTo 0
Next i
End If
End If
End Sub
I can continue to step through this until it eventually returns to
Range("D4").Select
Sheets("Act1").Select
It may then run the remainder of the coding but what I have tried so far produces more Runtime and type mismatch errors which I will post after I can fix this.
Bottom line is I dont want the change sheet tab code run - I need the remainder of the Sub CopyEmployed() to run.
Any ideas please?