I have a procedure to extract the initials from the name in a cell, and then assign the initials to a named range in the workbook. Originally I had the range as a hidden cell, so for my last line in this procedure, I just had:
Worksheets("Fix Checklist"
.Range("initials"
= UCase(init)
Range("initials"
referred to hidden cell A100.
Well now I would like to change this named range to not have a cell reference, but rather a value. So instead of setting the "Refers To" for the range name to a cell reference -- "=$A$100", I would like to set it to the value of my variable (in this procedure) called init.
Therefore, I changed the last line of the procedure to:
ActiveWorkbook.Names.Item("initials"
.RefersTo = init
Now I get the following error on that line of code:
Run-time error '1004':
Application-defined or object-defined error
Anyone know how to make this work?
Private Sub Extract_Initials()
Dim i As Long
Dim txt As String
Dim x() As String
Dim init As String
init = ""
txt = Worksheets("Fix Checklist"
.Range("YourName"
x() = Split(txt, " "
For i = 0 To UBound(x)
init = init + (Left(x(i), 1))
Next i
init = UCase(init)
ActiveWorkbook.Names.Item("initials"
.RefersTo = init
End Sub
Worksheets("Fix Checklist"
Range("initials"
Well now I would like to change this named range to not have a cell reference, but rather a value. So instead of setting the "Refers To" for the range name to a cell reference -- "=$A$100", I would like to set it to the value of my variable (in this procedure) called init.
Therefore, I changed the last line of the procedure to:
ActiveWorkbook.Names.Item("initials"
Now I get the following error on that line of code:
Run-time error '1004':
Application-defined or object-defined error
Anyone know how to make this work?
Private Sub Extract_Initials()
Dim i As Long
Dim txt As String
Dim x() As String
Dim init As String
init = ""
txt = Worksheets("Fix Checklist"
x() = Split(txt, " "
For i = 0 To UBound(x)
init = init + (Left(x(i), 1))
Next i
init = UCase(init)
ActiveWorkbook.Names.Item("initials"
End Sub