Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default Problem creating a named range

Code looks like this:

ActiveWorkbook.Names.Add Name:=varName, RefersTo:="Sheet!" & varStartCell


Creates a name, which I cannot use, because it is surrounded by quotation "
" symbols.
Note about Varname: is created after stripping out spaces from user entered
input; varStartCell is an absolute reference like $A$5

TY
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Problem creating a named range

Do you have a worksheet named: Sheet

And you dropped an equal sign in the refersto:= portion

RefersTo:="=Sheet!" & varStartCell

headly wrote:

Code looks like this:

ActiveWorkbook.Names.Add Name:=varName, RefersTo:="Sheet!" & varStartCell

Creates a name, which I cannot use, because it is surrounded by quotation "
" symbols.
Note about Varname: is created after stripping out spaces from user entered
input; varStartCell is an absolute reference like $A$5

TY


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Problem creating a named range

On Sun, 27 Jul 2008 16:49:29 -0700, headly
wrote:

Code looks like this:

ActiveWorkbook.Names.Add Name:=varName, RefersTo:="Sheet!" & varStartCell


Creates a name, which I cannot use, because it is surrounded by quotation "
" symbols.
Note about Varname: is created after stripping out spaces from user entered
input; varStartCell is an absolute reference like $A$5

TY


You're very close to the correct format. Note the equal sign AFTER the initial
quote.

ActiveWorkbook.Names.Add Name:=varName, RefersTo:="=Sheet!" & varStartCell
--ron
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 128
Default Problem creating a named range

On Jul 27, 5:48 pm, Dave Peterson wrote:
Do you have a worksheet named: Sheet

And you dropped an equal sign in the refersto:= portion

RefersTo:="=Sheet!" & varStartCell

headly wrote:

Code looks like this:


ActiveWorkbook.Names.Add Name:=varName, RefersTo:="Sheet!" & varStartCell


Creates a name, which I cannot use, because it is surrounded by quotation "
" symbols.
Note about Varname: is created after stripping out spaces from user entered
input; varStartCell is an absolute reference like $A$5


TY


--

Dave Peterson


Hello headly,

If you need the active sheet's name added to the reference, you can
use this code..

ActiveWorkbook.Names.Add Name:=varName, RefersTo:="='" &
ActiveSheet.Name & "'!" & varStartCell

Sincerely,
Leith Ross
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Problem creating a named range

You are missing an equals sign:

Sub Macro1()
Dim varName As String
Dim varStartCell As String
varName = "alpha"
varStartCell = "$A$5"
ActiveWorkbook.Names.Add Name:=varName, RefersTo:="=Sheet!" & varStartCell
End Sub
--
Gary''s Student - gsnu200796


"headly" wrote:

Code looks like this:

ActiveWorkbook.Names.Add Name:=varName, RefersTo:="Sheet!" & varStartCell


Creates a name, which I cannot use, because it is surrounded by quotation "
" symbols.
Note about Varname: is created after stripping out spaces from user entered
input; varStartCell is an absolute reference like $A$5

TY



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default Problem creating a named range

Actually, no, I get a name like ="sheet1!$A$5" but no idea where the "" came
from

"Gary''s Student" wrote:

You are missing an equals sign:

Sub Macro1()
Dim varName As String
Dim varStartCell As String
varName = "alpha"
varStartCell = "$A$5"
ActiveWorkbook.Names.Add Name:=varName, RefersTo:="=Sheet!" & varStartCell
End Sub
--
Gary''s Student - gsnu200796


"headly" wrote:

Code looks like this:

ActiveWorkbook.Names.Add Name:=varName, RefersTo:="Sheet!" & varStartCell


Creates a name, which I cannot use, because it is surrounded by quotation "
" symbols.
Note about Varname: is created after stripping out spaces from user entered
input; varStartCell is an absolute reference like $A$5

TY

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Problem creating a named range

Put a stop in your code just before naming the range like the following then
while it is stopped and before cancelling the process, rest your cursor over
the variables varName and then varStartCell and see what value VBA has
assigned to them.

varName = "MyNamedRange" 'Just as demo. No doubt your code is different
varStartCell = "$A$5"

Stop

ActiveWorkbook.Names.Add Name:=varName, RefersTo:="Sheet!" & varStartCell


If you can't fix then post a bit more of your code showing how varName and
varStartCell are populated and manipulated. ie stipped of blanks etc.

--
Regards,

OssieMac


"headly" wrote:

Actually, no, I get a name like ="sheet1!$A$5" but no idea where the "" came
from

"Gary''s Student" wrote:

You are missing an equals sign:

Sub Macro1()
Dim varName As String
Dim varStartCell As String
varName = "alpha"
varStartCell = "$A$5"
ActiveWorkbook.Names.Add Name:=varName, RefersTo:="=Sheet!" & varStartCell
End Sub
--
Gary''s Student - gsnu200796


"headly" wrote:

Code looks like this:

ActiveWorkbook.Names.Add Name:=varName, RefersTo:="Sheet!" & varStartCell


Creates a name, which I cannot use, because it is surrounded by quotation "
" symbols.
Note about Varname: is created after stripping out spaces from user entered
input; varStartCell is an absolute reference like $A$5

TY

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Problem creating a named range

On Sun, 27 Jul 2008 18:27:02 -0700, headly
wrote:

Actually, no, I get a name like ="sheet1!$A$5" but no idea where the "" came
from


If you put in the "=" sign where we have all been telling you to, those "" will
go away.
--ron
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a named range? dksaluki Excel Discussion (Misc queries) 2 February 22nd 08 03:12 AM
Problem with creating a named range Alex Excel Programming 11 May 9th 06 03:41 AM
Creating a named range Gixxer_J_97[_2_] Excel Programming 4 December 7th 05 10:06 PM
Can I use named range in data range box when creating pie chart? BJackson Charts and Charting in Excel 2 August 17th 05 05:37 PM
Creating a Named Range using VB Adriaan van der Linde Excel Programming 4 December 5th 03 01:05 PM


All times are GMT +1. The time now is 04:37 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"