PC Review


Reply
Thread Tools Rate Thread

Creating Name with variable

 
 
Asif
Guest
Posts: n/a
 
      18th Jul 2008
Hi there,

I am trying to create Names with the following statement:

ActiveWorkbook.Names.Add Name:="vld" & sVldName, RefersTo:=vldFormula

I keep getting the runtime error 1004. I will appreciate if somebody would
help me getting round this probelm.

--
Thanx & regards,
Asif
 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      18th Jul 2008
What is in vldName and vldFormula?

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Asif" <(E-Mail Removed)> wrote in message
newsD017C8C-5959-4B05-AD00-(E-Mail Removed)...
> Hi there,
>
> I am trying to create Names with the following statement:
>
> ActiveWorkbook.Names.Add Name:="vld" & sVldName, RefersTo:=vldFormula
>
> I keep getting the runtime error 1004. I will appreciate if somebody would
> help me getting round this probelm.
>
> --
> Thanx & regards,
> Asif



 
Reply With Quote
 
Asif
Guest
Posts: n/a
 
      18th Jul 2008
Here are the definitions of variables:

Dim vldFormula As String, sVldName As String

sVldName = WorksheetFunction.Index(vldNames, numNames, 0)

vldFormula = "=OFFSET(Data!$B$2,MATCH(Data!$I$" & numNames + 2 & _
",Data!$B$3:$B$65536,0),3,COUNTIF(Data!$B$B,Data!$I$" &
numNames + 2 & "),1)"

--
Thanx & regards,
Asif


"Bob Phillips" wrote:

> What is in vldName and vldFormula?
>
> --
> HTH
>
> Bob
>
> (there's no email, no snail mail, but somewhere should be gmail in my addy)
>
> "Asif" <(E-Mail Removed)> wrote in message
> newsD017C8C-5959-4B05-AD00-(E-Mail Removed)...
> > Hi there,
> >
> > I am trying to create Names with the following statement:
> >
> > ActiveWorkbook.Names.Add Name:="vld" & sVldName, RefersTo:=vldFormula
> >
> > I keep getting the runtime error 1004. I will appreciate if somebody would
> > help me getting round this probelm.
> >
> > --
> > Thanx & regards,
> > Asif

>
>
>

 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      18th Jul 2008
I got an error in the formula. See if this sorts it

vldFormula = "=OFFSET(Data!$B$2,MATCH(Data!$I$" & numNames + 2 & _
",Data!$B$3:$B$65536,0),3,COUNTIF(Data!$B:$B,Data!$I$" &
numNames + 2 & "),1)"


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Asif" <(E-Mail Removed)> wrote in message
news:8F4D1DD2-52E9-4EB0-B37A-(E-Mail Removed)...
> Here are the definitions of variables:
>
> Dim vldFormula As String, sVldName As String
>
> sVldName = WorksheetFunction.Index(vldNames, numNames, 0)
>
> vldFormula = "=OFFSET(Data!$B$2,MATCH(Data!$I$" & numNames + 2 & _
> ",Data!$B$3:$B$65536,0),3,COUNTIF(Data!$B$B,Data!$I$" &
> numNames + 2 & "),1)"
>
> --
> Thanx & regards,
> Asif
>
>
> "Bob Phillips" wrote:
>
>> What is in vldName and vldFormula?
>>
>> --
>> HTH
>>
>> Bob
>>
>> (there's no email, no snail mail, but somewhere should be gmail in my
>> addy)
>>
>> "Asif" <(E-Mail Removed)> wrote in message
>> newsD017C8C-5959-4B05-AD00-(E-Mail Removed)...
>> > Hi there,
>> >
>> > I am trying to create Names with the following statement:
>> >
>> > ActiveWorkbook.Names.Add Name:="vld" & sVldName, RefersTo:=vldFormula
>> >
>> > I keep getting the runtime error 1004. I will appreciate if somebody
>> > would
>> > help me getting round this probelm.
>> >
>> > --
>> > Thanx & regards,
>> > Asif

>>
>>
>>



 
Reply With Quote
 
Asif
Guest
Posts: n/a
 
      18th Jul 2008
Hi Bob,

I have following statement now which is causing the same runtime error

ActiveWorkbook.Names.Item("vld" & sVldName).Delete

Above statement is before the assignment statements below.

--
Thanx & regards,
Asif


"Bob Phillips" wrote:

> I got an error in the formula. See if this sorts it
>
> vldFormula = "=OFFSET(Data!$B$2,MATCH(Data!$I$" & numNames + 2 & _
> ",Data!$B$3:$B$65536,0),3,COUNTIF(Data!$B:$B,Data!$I$" &
> numNames + 2 & "),1)"
>
>
> --
> HTH
>
> Bob
>
> (there's no email, no snail mail, but somewhere should be gmail in my addy)
>
> "Asif" <(E-Mail Removed)> wrote in message
> news:8F4D1DD2-52E9-4EB0-B37A-(E-Mail Removed)...
> > Here are the definitions of variables:
> >
> > Dim vldFormula As String, sVldName As String
> >
> > sVldName = WorksheetFunction.Index(vldNames, numNames, 0)
> >
> > vldFormula = "=OFFSET(Data!$B$2,MATCH(Data!$I$" & numNames + 2 & _
> > ",Data!$B$3:$B$65536,0),3,COUNTIF(Data!$B$B,Data!$I$" &
> > numNames + 2 & "),1)"
> >
> > --
> > Thanx & regards,
> > Asif
> >
> >
> > "Bob Phillips" wrote:
> >
> >> What is in vldName and vldFormula?
> >>
> >> --
> >> HTH
> >>
> >> Bob
> >>
> >> (there's no email, no snail mail, but somewhere should be gmail in my
> >> addy)
> >>
> >> "Asif" <(E-Mail Removed)> wrote in message
> >> newsD017C8C-5959-4B05-AD00-(E-Mail Removed)...
> >> > Hi there,
> >> >
> >> > I am trying to create Names with the following statement:
> >> >
> >> > ActiveWorkbook.Names.Add Name:="vld" & sVldName, RefersTo:=vldFormula
> >> >
> >> > I keep getting the runtime error 1004. I will appreciate if somebody
> >> > would
> >> > help me getting round this probelm.
> >> >
> >> > --
> >> > Thanx & regards,
> >> > Asif
> >>
> >>
> >>

>
>
>

 
Reply With Quote
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      18th Jul 2008
When you say it is "before the assignment statements below", do you mean it
is before this one?

sVldName = WorksheetFunction.Index(vldNames, numNames, 0)

In other words, do you mean you are trying to use sVldName **before** you
assign anything to it?

Rick


"Asif" <(E-Mail Removed)> wrote in message
news:0F732F01-5A72-4709-847C-(E-Mail Removed)...
> Hi Bob,
>
> I have following statement now which is causing the same runtime error
>
> ActiveWorkbook.Names.Item("vld" & sVldName).Delete
>
> Above statement is before the assignment statements below.
>
> --
> Thanx & regards,
> Asif
>
>
> "Bob Phillips" wrote:
>
>> I got an error in the formula. See if this sorts it
>>
>> vldFormula = "=OFFSET(Data!$B$2,MATCH(Data!$I$" & numNames + 2 & _
>> ",Data!$B$3:$B$65536,0),3,COUNTIF(Data!$B:$B,Data!$I$" &
>> numNames + 2 & "),1)"
>>
>>
>> --
>> HTH
>>
>> Bob
>>
>> (there's no email, no snail mail, but somewhere should be gmail in my
>> addy)
>>
>> "Asif" <(E-Mail Removed)> wrote in message
>> news:8F4D1DD2-52E9-4EB0-B37A-(E-Mail Removed)...
>> > Here are the definitions of variables:
>> >
>> > Dim vldFormula As String, sVldName As String
>> >
>> > sVldName = WorksheetFunction.Index(vldNames, numNames, 0)
>> >
>> > vldFormula = "=OFFSET(Data!$B$2,MATCH(Data!$I$" & numNames + 2 & _
>> > ",Data!$B$3:$B$65536,0),3,COUNTIF(Data!$B$B,Data!$I$" &
>> > numNames + 2 & "),1)"
>> >
>> > --
>> > Thanx & regards,
>> > Asif
>> >
>> >
>> > "Bob Phillips" wrote:
>> >
>> >> What is in vldName and vldFormula?
>> >>
>> >> --
>> >> HTH
>> >>
>> >> Bob
>> >>
>> >> (there's no email, no snail mail, but somewhere should be gmail in my
>> >> addy)
>> >>
>> >> "Asif" <(E-Mail Removed)> wrote in message
>> >> newsD017C8C-5959-4B05-AD00-(E-Mail Removed)...
>> >> > Hi there,
>> >> >
>> >> > I am trying to create Names with the following statement:
>> >> >
>> >> > ActiveWorkbook.Names.Add Name:="vld" & sVldName,
>> >> > RefersTo:=vldFormula
>> >> >
>> >> > I keep getting the runtime error 1004. I will appreciate if somebody
>> >> > would
>> >> > help me getting round this probelm.
>> >> >
>> >> > --
>> >> > Thanx & regards,
>> >> > Asif
>> >>
>> >>
>> >>

>>
>>
>>


 
Reply With Quote
 
Asif
Guest
Posts: n/a
 
      18th Jul 2008
Please see below the whole block:

For numNames = 1 To NamesCount
sVldName = WorksheetFunction.Index(vldNames, numNames, 0)
ActiveWorkbook.Names.Item("vld" & sVldName).Delete
vldFormula = "=OFFSET(Data!$B$2,MATCH(Data!$I$" & numNames + 2 &
",Data!$B$3:$B$65536,0),3,COUNTIF(Data!$B:$B,Data!$I$" & numNames + 2 & "),1)"
ActiveWorkbook.Names.Add Name:="vld" & sVldName, RefersTo:=vldFormula
Next numNames
--
Thanx & regards,
Asif


"Rick Rothstein (MVP - VB)" wrote:

> When you say it is "before the assignment statements below", do you mean it
> is before this one?
>
> sVldName = WorksheetFunction.Index(vldNames, numNames, 0)
>
> In other words, do you mean you are trying to use sVldName **before** you
> assign anything to it?
>
> Rick
>
>
> "Asif" <(E-Mail Removed)> wrote in message
> news:0F732F01-5A72-4709-847C-(E-Mail Removed)...
> > Hi Bob,
> >
> > I have following statement now which is causing the same runtime error
> >
> > ActiveWorkbook.Names.Item("vld" & sVldName).Delete
> >
> > Above statement is before the assignment statements below.
> >
> > --
> > Thanx & regards,
> > Asif
> >
> >
> > "Bob Phillips" wrote:
> >
> >> I got an error in the formula. See if this sorts it
> >>
> >> vldFormula = "=OFFSET(Data!$B$2,MATCH(Data!$I$" & numNames + 2 & _
> >> ",Data!$B$3:$B$65536,0),3,COUNTIF(Data!$B:$B,Data!$I$" &
> >> numNames + 2 & "),1)"
> >>
> >>
> >> --
> >> HTH
> >>
> >> Bob
> >>
> >> (there's no email, no snail mail, but somewhere should be gmail in my
> >> addy)
> >>
> >> "Asif" <(E-Mail Removed)> wrote in message
> >> news:8F4D1DD2-52E9-4EB0-B37A-(E-Mail Removed)...
> >> > Here are the definitions of variables:
> >> >
> >> > Dim vldFormula As String, sVldName As String
> >> >
> >> > sVldName = WorksheetFunction.Index(vldNames, numNames, 0)
> >> >
> >> > vldFormula = "=OFFSET(Data!$B$2,MATCH(Data!$I$" & numNames + 2 & _
> >> > ",Data!$B$3:$B$65536,0),3,COUNTIF(Data!$B$B,Data!$I$" &
> >> > numNames + 2 & "),1)"
> >> >
> >> > --
> >> > Thanx & regards,
> >> > Asif
> >> >
> >> >
> >> > "Bob Phillips" wrote:
> >> >
> >> >> What is in vldName and vldFormula?
> >> >>
> >> >> --
> >> >> HTH
> >> >>
> >> >> Bob
> >> >>
> >> >> (there's no email, no snail mail, but somewhere should be gmail in my
> >> >> addy)
> >> >>
> >> >> "Asif" <(E-Mail Removed)> wrote in message
> >> >> newsD017C8C-5959-4B05-AD00-(E-Mail Removed)...
> >> >> > Hi there,
> >> >> >
> >> >> > I am trying to create Names with the following statement:
> >> >> >
> >> >> > ActiveWorkbook.Names.Add Name:="vld" & sVldName,
> >> >> > RefersTo:=vldFormula
> >> >> >
> >> >> > I keep getting the runtime error 1004. I will appreciate if somebody
> >> >> > would
> >> >> > help me getting round this probelm.
> >> >> >
> >> >> > --
> >> >> > Thanx & regards,
> >> >> > Asif
> >> >>
> >> >>
> >> >>
> >>
> >>
> >>

>
>

 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      18th Jul 2008
Don't bother deleting it, not necessary to re-create it.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Asif" <(E-Mail Removed)> wrote in message
news:6457DFD9-24CD-4FB5-867D-(E-Mail Removed)...
> Please see below the whole block:
>
> For numNames = 1 To NamesCount
> sVldName = WorksheetFunction.Index(vldNames, numNames, 0)
> ActiveWorkbook.Names.Item("vld" & sVldName).Delete
> vldFormula = "=OFFSET(Data!$B$2,MATCH(Data!$I$" & numNames + 2 &
> ",Data!$B$3:$B$65536,0),3,COUNTIF(Data!$B:$B,Data!$I$" & numNames + 2 &
> "),1)"
> ActiveWorkbook.Names.Add Name:="vld" & sVldName, RefersTo:=vldFormula
> Next numNames
> --
> Thanx & regards,
> Asif
>
>
> "Rick Rothstein (MVP - VB)" wrote:
>
>> When you say it is "before the assignment statements below", do you mean
>> it
>> is before this one?
>>
>> sVldName = WorksheetFunction.Index(vldNames, numNames, 0)
>>
>> In other words, do you mean you are trying to use sVldName **before** you
>> assign anything to it?
>>
>> Rick
>>
>>
>> "Asif" <(E-Mail Removed)> wrote in message
>> news:0F732F01-5A72-4709-847C-(E-Mail Removed)...
>> > Hi Bob,
>> >
>> > I have following statement now which is causing the same runtime error
>> >
>> > ActiveWorkbook.Names.Item("vld" & sVldName).Delete
>> >
>> > Above statement is before the assignment statements below.
>> >
>> > --
>> > Thanx & regards,
>> > Asif
>> >
>> >
>> > "Bob Phillips" wrote:
>> >
>> >> I got an error in the formula. See if this sorts it
>> >>
>> >> vldFormula = "=OFFSET(Data!$B$2,MATCH(Data!$I$" & numNames + 2 & _
>> >> ",Data!$B$3:$B$65536,0),3,COUNTIF(Data!$B:$B,Data!$I$" &
>> >> numNames + 2 & "),1)"
>> >>
>> >>
>> >> --
>> >> HTH
>> >>
>> >> Bob
>> >>
>> >> (there's no email, no snail mail, but somewhere should be gmail in my
>> >> addy)
>> >>
>> >> "Asif" <(E-Mail Removed)> wrote in message
>> >> news:8F4D1DD2-52E9-4EB0-B37A-(E-Mail Removed)...
>> >> > Here are the definitions of variables:
>> >> >
>> >> > Dim vldFormula As String, sVldName As String
>> >> >
>> >> > sVldName = WorksheetFunction.Index(vldNames, numNames, 0)
>> >> >
>> >> > vldFormula = "=OFFSET(Data!$B$2,MATCH(Data!$I$" & numNames + 2 & _
>> >> > ",Data!$B$3:$B$65536,0),3,COUNTIF(Data!$B$B,Data!$I$"
>> >> > &
>> >> > numNames + 2 & "),1)"
>> >> >
>> >> > --
>> >> > Thanx & regards,
>> >> > Asif
>> >> >
>> >> >
>> >> > "Bob Phillips" wrote:
>> >> >
>> >> >> What is in vldName and vldFormula?
>> >> >>
>> >> >> --
>> >> >> HTH
>> >> >>
>> >> >> Bob
>> >> >>
>> >> >> (there's no email, no snail mail, but somewhere should be gmail in
>> >> >> my
>> >> >> addy)
>> >> >>
>> >> >> "Asif" <(E-Mail Removed)> wrote in message
>> >> >> newsD017C8C-5959-4B05-AD00-(E-Mail Removed)...
>> >> >> > Hi there,
>> >> >> >
>> >> >> > I am trying to create Names with the following statement:
>> >> >> >
>> >> >> > ActiveWorkbook.Names.Add Name:="vld" & sVldName,
>> >> >> > RefersTo:=vldFormula
>> >> >> >
>> >> >> > I keep getting the runtime error 1004. I will appreciate if
>> >> >> > somebody
>> >> >> > would
>> >> >> > help me getting round this probelm.
>> >> >> >
>> >> >> > --
>> >> >> > Thanx & regards,
>> >> >> > Asif
>> >> >>
>> >> >>
>> >> >>
>> >>
>> >>
>> >>

>>
>>



 
Reply With Quote
 
Asif
Guest
Posts: n/a
 
      18th Jul 2008
Thank you Bob. This is working now.

--
Thanx & regards,
Asif


"Bob Phillips" wrote:

> Don't bother deleting it, not necessary to re-create it.
>
> --
> HTH
>
> Bob
>
> (there's no email, no snail mail, but somewhere should be gmail in my addy)
>
> "Asif" <(E-Mail Removed)> wrote in message
> news:6457DFD9-24CD-4FB5-867D-(E-Mail Removed)...
> > Please see below the whole block:
> >
> > For numNames = 1 To NamesCount
> > sVldName = WorksheetFunction.Index(vldNames, numNames, 0)
> > ActiveWorkbook.Names.Item("vld" & sVldName).Delete
> > vldFormula = "=OFFSET(Data!$B$2,MATCH(Data!$I$" & numNames + 2 &
> > ",Data!$B$3:$B$65536,0),3,COUNTIF(Data!$B:$B,Data!$I$" & numNames + 2 &
> > "),1)"
> > ActiveWorkbook.Names.Add Name:="vld" & sVldName, RefersTo:=vldFormula
> > Next numNames
> > --
> > Thanx & regards,
> > Asif
> >
> >
> > "Rick Rothstein (MVP - VB)" wrote:
> >
> >> When you say it is "before the assignment statements below", do you mean
> >> it
> >> is before this one?
> >>
> >> sVldName = WorksheetFunction.Index(vldNames, numNames, 0)
> >>
> >> In other words, do you mean you are trying to use sVldName **before** you
> >> assign anything to it?
> >>
> >> Rick
> >>
> >>
> >> "Asif" <(E-Mail Removed)> wrote in message
> >> news:0F732F01-5A72-4709-847C-(E-Mail Removed)...
> >> > Hi Bob,
> >> >
> >> > I have following statement now which is causing the same runtime error
> >> >
> >> > ActiveWorkbook.Names.Item("vld" & sVldName).Delete
> >> >
> >> > Above statement is before the assignment statements below.
> >> >
> >> > --
> >> > Thanx & regards,
> >> > Asif
> >> >
> >> >
> >> > "Bob Phillips" wrote:
> >> >
> >> >> I got an error in the formula. See if this sorts it
> >> >>
> >> >> vldFormula = "=OFFSET(Data!$B$2,MATCH(Data!$I$" & numNames + 2 & _
> >> >> ",Data!$B$3:$B$65536,0),3,COUNTIF(Data!$B:$B,Data!$I$" &
> >> >> numNames + 2 & "),1)"
> >> >>
> >> >>
> >> >> --
> >> >> HTH
> >> >>
> >> >> Bob
> >> >>
> >> >> (there's no email, no snail mail, but somewhere should be gmail in my
> >> >> addy)
> >> >>
> >> >> "Asif" <(E-Mail Removed)> wrote in message
> >> >> news:8F4D1DD2-52E9-4EB0-B37A-(E-Mail Removed)...
> >> >> > Here are the definitions of variables:
> >> >> >
> >> >> > Dim vldFormula As String, sVldName As String
> >> >> >
> >> >> > sVldName = WorksheetFunction.Index(vldNames, numNames, 0)
> >> >> >
> >> >> > vldFormula = "=OFFSET(Data!$B$2,MATCH(Data!$I$" & numNames + 2 & _
> >> >> > ",Data!$B$3:$B$65536,0),3,COUNTIF(Data!$B$B,Data!$I$"
> >> >> > &
> >> >> > numNames + 2 & "),1)"
> >> >> >
> >> >> > --
> >> >> > Thanx & regards,
> >> >> > Asif
> >> >> >
> >> >> >
> >> >> > "Bob Phillips" wrote:
> >> >> >
> >> >> >> What is in vldName and vldFormula?
> >> >> >>
> >> >> >> --
> >> >> >> HTH
> >> >> >>
> >> >> >> Bob
> >> >> >>
> >> >> >> (there's no email, no snail mail, but somewhere should be gmail in
> >> >> >> my
> >> >> >> addy)
> >> >> >>
> >> >> >> "Asif" <(E-Mail Removed)> wrote in message
> >> >> >> newsD017C8C-5959-4B05-AD00-(E-Mail Removed)...
> >> >> >> > Hi there,
> >> >> >> >
> >> >> >> > I am trying to create Names with the following statement:
> >> >> >> >
> >> >> >> > ActiveWorkbook.Names.Add Name:="vld" & sVldName,
> >> >> >> > RefersTo:=vldFormula
> >> >> >> >
> >> >> >> > I keep getting the runtime error 1004. I will appreciate if
> >> >> >> > somebody
> >> >> >> > would
> >> >> >> > help me getting round this probelm.
> >> >> >> >
> >> >> >> > --
> >> >> >> > Thanx & regards,
> >> >> >> > Asif
> >> >> >>
> >> >> >>
> >> >> >>
> >> >>
> >> >>
> >> >>
> >>
> >>

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
creating a variable =?Utf-8?B?QWJl?= Microsoft Excel New Users 1 15th Apr 2006 06:41 AM
Creating a variable within a field =?Utf-8?B?RXJpayBHcmVlbmU=?= Microsoft Access Reports 1 25th May 2005 04:41 PM
Urgent: Creating an Environment Variable (System Variable)? =?Utf-8?B?U2F1cmFiaA==?= Microsoft Dot NET Framework 1 7th Feb 2005 05:51 PM
Creating my on variable =?Utf-8?B?Um9ieSBFIE1hcnRpbnM=?= Microsoft Dot NET Framework 7 10th Nov 2004 10:34 PM
Macro Creating Variable and using variable in a SQL statement =?Utf-8?B?SmltbXk=?= Microsoft Excel Programming 4 25th Oct 2004 02:36 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:22 AM.