See attached file, I hope it's what you need.
This is the macro I added:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count = 1 Then
If Target.Address(0, 0) = "C2" Then
'change group number
Rows("4:20").Hidden = True
Rows("4:" & 3 + CInt(Target)).Hidden = False
Call FullRows
ElseIf Target.Row >= 4 And Target.Row <= 20 _
And Target.Column <= 2 Then
'change group/number
Call FullRows
End If
End If
End Sub
Sub FullRows()
Dim groupNum As Integer, destRow As Long
Dim g As Integer, p As Integer
Application.EnableEvents = False
Application.ScreenUpdating = False
With ThisWorkbook.ActiveSheet
.Rows("21:130").ClearContents
groupNum = .Range("c2")
destRow = 20
For g = 1 To groupNum
For p = 1 To .Cells(3 + g, 2)
destRow = destRow + 1
.Cells(destRow, 1) = "'" & g & "." & Asc(.Cells(3 + g, 1)) - 64 & p
.Cells(destRow, 2) = .Cells(3 + g, 1) & .Cells(3 + g, 2)
Next p
Next g
End With
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
Regards,
Antonio
Bookmarks