Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have a set of parameters and I want to assign names for each with the values b

ID: 3561941 • Letter: I

Question

I have a set of parameters and I want to assign names for each with the values being constants. As far ass I can tell though my only option is to define each one manually. The data is listed in two adjaceent columns; A contaaining the names, B containing the values. If I create the names by selection then the values are ceell references. Am I missing something? Is there a way to create by selection while defining the names as constants??? Or is there a way to convert the cell references to constants, other than by editing them one at a time???   

Explanation / Answer

You can pick up just about any beginning VBA book for XL around - the basics are the same as Windows, though there are a number of differences (especially with ActiveX controls). There are also any number of web sites that will give tutorials

Here's one way to do what you're asking for:

Public Sub CreateConstantNamesFromRange()

Dim rCell As Range

Dim oNames As Names

  

On Error GoTo ErrHandler

Set>

For Each rCell In Selection.Columns(1).Cells

With rCell

oNames.Add Name:=.Text, RefersTo:=.Offset(0, 1).Text

End With

Next rCell

ExitSub:

Exit Sub

ErrHandler:

Debug.Print Err.Number, Err.Description

Resume ExitSub

End Sub

If you're looking for worksheet-level names, use

Set>

on the fifth linee (vs. ActiveWorkbbook).

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote