Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8806487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:08:15+00:00 2026-06-14T02:08:15+00:00

I want to populate the name box for a cell with the value from

  • 0

I want to populate the name box for a cell with the value from an adjacent cell. This macro works.

Sub NameBox()
   ' populates name box w/ value from adjacent cell
   ActiveCell.Name = ActiveCell.Offset(0, -1).Value
   ' steps down to next cell
   ActiveCell.Offset(1, 0).Select
End Sub

I assign a key stroke and iterate through each cell in the column which is pretty easy but I think it can be improved with a loop.

I tried this.

Sub NameBoxLoop()
   Dim cel As Range
   For Each cel In Range("C:C").Cells
      If cel.Value <> "" Then
         cel.Name = cel.Offset(0, -1).Value
      End If
   Next cel
End Sub

But I get the following debug error

cel.Name = Application-defined or object-defined error

The loop logic looks right, if I replace the variable cel.Name with cel.Value the loop will complete.

Searches haven’t provided an answer to the cel.Name error. Any help in resolving this error is appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T02:08:16+00:00Added an answer on June 14, 2026 at 2:08 am

    Your formula works. But maybe your environment is not optimal, because you have no error-correction there – and names have limitations.

    So I am guessing eigther you don’t have values in column B or column B has values which are already used as names for other cells.

    In both cases your loop would break.

    Try this to loop anyways, but consider error-proving your code:

    Sub NameBoxLoop()
       On Error Resume Next
       Dim cel As Range
       For Each cel In Range("C:C").Cells
          If cel.Value <> "" Then
             cel.Name = cel.Offset(0, -1).Value
          End If
       Next cel
    end sub
    

    Edit:

    as a suggestion, you might want to consider using the Names listing.

    Here is an example from excel-help:

    ActiveWorkbook.Names.Add Name:="test", RefersTo:="=sheet1!$a$1:$c$20"
    

    And here some of the objectmembers:

    • Add
    • Item
    • Count
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want to populate combo box with the session data ex:Name of user in
I want to populate a drop down menu with a column from a MySQL
When i want to populate my grid I use this Select command : SELECT
I have used this statements to populate jcombobox from MySql database table using Hibernate
I want to populate the combobox dynamically based on the data I received from
If I have a Html.TextAreaFor(x=>x.Name) and I want to read its value how do
i have this code to populate the option in my select box(i have 7
I want to populate my database with test data my user and profile models
I want to populate a table form a MYSQL database. I have defined the
I want to populate GridView below with images: <asp:GridView ID=GrdDynamic runat=server AutoGenerateColumns=False> <Columns> </Columns>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.