For each cell with content in range C4:C53 of worksheet "Size Selection", I want to create a new named range, and the name of that range should be the same as the content of that cell.
Each of the named ranges should be formula driven, and has a variable that depends on the row of the cell.
I've tried coding this, but keep getting errors; would you please take a look and help me resolve the issue?
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A1:F20000")) Is Nothing Then
Dim i As Integer
Dim range_name As String
For i = 4 To 53
If Sheets("Size Selection").Cells(i, 3) <> "" Then
Range(range_name).Formula = "=OFFSET('Size Selection'!$F$" & i & ", 0, 0, 1, COUNT(IF('Size Selection'!$F$" & i & ":$AZ$" & i & "="", "", 1)))"
Range(range_name).Name = Sheets("Size Selection").Cells(i, 3)
End If
Next
End If
End Sub
Many thanks for your help!
range_nameis an empty string every time. You need to populate it correctly.