locked
Change Excel Cell Name with VB

    Question

  • Can someone please tell me in VB how to change the name of a cell in Excel.  E.g to change "A1" to "NewCellName"

    I can change the value of the cell as follows, but I cannot find how to change the cell name:

    Dim MyExcel As New Application

    Dim wb As Workbook

    wb = MyExcel.Workbooks.Open(ExcelFile)

    MyExcel.Cells(1, 1) = "a value"

    But I need to change the name of the cell...
    Please help
    Ric.

    Thursday, November 20, 2008 4:16 PM

Answers

  • I think you you want to change range name

     wb.Worksheets(1).Range("A1").Name = "NewCellName"
    wb.save()
    wb.close()

    Arjun Paudel
    • Proposed as answer by konikula Sunday, November 23, 2008 7:35 AM
    • Marked as answer by Ric Fisher Sunday, November 23, 2008 9:54 AM
    Thursday, November 20, 2008 5:02 PM

All replies

  • I think you you want to change range name

     wb.Worksheets(1).Range("A1").Name = "NewCellName"
    wb.save()
    wb.close()

    Arjun Paudel
    • Proposed as answer by konikula Sunday, November 23, 2008 7:35 AM
    • Marked as answer by Ric Fisher Sunday, November 23, 2008 9:54 AM
    Thursday, November 20, 2008 5:02 PM
  • Many Thanks Arjun,
    That worked like a treat...
    Sunday, November 23, 2008 9:53 AM