I'm trying to name intervals in every worksheet according to the content of a specific cell in each worksheet. I've looked up many ways of naming the ranges, whoever none uses the content of a cell as a name. This is what I have (but it doesn't work):
Sub NameRanges()
Dim WS_Count As Integer
Dim I As Integer
Dim r As String
WS_Count = ActiveWorkbook.Worksheets.Count
For I = 5 To WS_Count
r = Worksheets(I).Range("A2")
Names.Add Name:="r", RefersTo:=Worksheets(I).Range("B6:B10000")
Next I
End Sub
Names.Add Name:=r? Variables don't belong inside quotes.