I have cells A2 through A20 Would like to generate a new worksheet when cell values within that range change.
Additionally, the new worksheet generated would be renamed to the value of the changed cell.
I had this code working properly (for a single cell), until the range was requested by the user
Private Sub Worksheet_Change(ByVal Target As Range)
Dim KeyCells As Range
Dim ws As Worksheet
Dim lastrow As Long
lastrow = ActiveSheet.Cells(Rows.Count, "D").End(xlUp).Row + 1
Set KeyCells = Range("B5")
If Not Application.Intersect(KeyCells, Range(Target.Address)) _
Is Nothing Then
For Each ws In Worksheets
With ActiveSheet
If .Range("B5").Value <> "" Then .Name = .Range("B5").Value
End With
Cells(lastrow, "D").Value = Range("B5").Value
End If
End Sub