incrementing R1C1 Reference using loop

  • Hi.,


    I am trying to create name list for a column. my values are in Column A up to 10 rows, i would like to assign name in B column corresponding rows. For ex: for LenZ in R1C1, the list name in R1C2, should be LenZ ( ie same name). i tried a lot but unable to increment the R1C1 value. Can anyone help on this.

    Code
    Sub kre3()
    Dim rw As Integer, cl As Integer
    
    rw = 1
    cl = 2
    If rw = 10 Then    ActiveWorkbook.Names.Add Name:=Cells(rw, 1), RefersToR1C1:="=Sheet1!R[" & rw & "]C[" & cl & "]"
    rw = rw + 1
    End If End Sub
  • I think you are creating named ranges? There is no loop in the code you are using, I am not exactly sure what you are trying to do but I think it is something like this:


    Code
    Sub kre3()
    Dim rw As Integer, cl As Integer
    rw = 1
    cl = 2
    For rw = 1 To 10
    ActiveWorkbook.Names.Add Name:=Sheet1.Cells(rw, 1).Value, RefersTo:=Sheet1.Cells(rw, 2)
    Next rw
    End Sub

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!