If you want to use macros instead of formulas, then use the following:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$D$4" Or Target.Address = "$H$4" Then
If Target = vbNullString Then Exit Sub
If Range("D4") > Range("H4") Then Exit Sub
Application.EnableEvents = False
Range(Cells(6, 2), Cells(6, Cells(6, Columns.Count).End(xlToLeft).Column)).ClearContents
Dim x&, y&
For x = Range("D4") To Range("H4")
Range("B6").Offset(0, y) = x
Range("B6").Offset(0, y).NumberFormat = Range("D4").NumberFormat
y = y + 1
Next x
Application.EnableEvents = True
Else
End If
End Sub
Bookmarks