C1 houses "Products". The vba-code:
ActiveWorkbook.Names.Add Name:=Cells(1, 3).Value, RefersToR1C1:="=Sheet1!R2C2:R2C6"
gives C2:C6 the name "Products".
To name the ranges C2:C6, D2:D6, …..K2:K6, I tried:
Dim k as integer
For k = 3 to 9
ActiveWorkbook.Names.Add Name:=Cells(1, k), RefersToR1C1:="=Sheet1!R2Ck:R6Ck"
Next k
but that doesn't work. The k in Sheet1!R2Ck:R6Ck is not accepted.
What can I do?
ActiveWorkbook.Names.Add Name:=Cells(1, 3).Value, RefersToR1C1:="=Sheet1!R2C2:R2C6"
gives C2:C6 the name "Products".
To name the ranges C2:C6, D2:D6, …..K2:K6, I tried:
Dim k as integer
For k = 3 to 9
ActiveWorkbook.Names.Add Name:=Cells(1, k), RefersToR1C1:="=Sheet1!R2Ck:R6Ck"
Next k
but that doesn't work. The k in Sheet1!R2Ck:R6Ck is not accepted.
What can I do?