PC Review


Reply
Thread Tools Rate Thread

Code to change a named range

 
 
Brian
Guest
Posts: n/a
 
      13th Apr 2010
Hello,

I have a macro that runs and it ends up having to delete row 2 on 2
different sheets, which I do with..... which I am only showing a portion to
make it short and easy. This causes a problem is it causes my named range to
have a #REF where it used to say $B$2.

With .Worksheets("BO Ref List")
.Range("A1").PasteSpecial
.Columns("A:B").RemoveDuplicates Columns:=Array(1, 2),
Header:=xlYes
.Range("A2:B2").Delete Shift:=xlUp

With .Worksheets("FO Ref List")
.Range("A1").PasteSpecial
.Columns("A:B").RemoveDuplicates Columns:=Array(1, 2),
Header:=xlYes
.Range("A2:B2").Delete Shift:=xlUp

Here is the actual formula in my named range....
BOAssociate "=OFFSET('BO Ref List'!$B$2,0,0,COUNTA('BO Ref
List'!$B$2:$B$989),1)"
FOAssociate "=OFFSET('FO Ref List'!$B$2,0,0,COUNTA('FO Ref
List'!$B$2:$B$985),1)"

I have attempted using a few different things, but I am drawing a blank when
it comes to writing it into my macro to have it change the named range back
to the above.


 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      13th Apr 2010

Why not just recreate it?

.Names.Add Name:="BOAssociate", RefersTo:="=OFFSET('BO Ref
List'!$B$2,0,0,COUNTA('BO Ref List'!$B$2:$B$989),1)"

--

HTH

Bob

"Brian" <(E-Mail Removed)> wrote in message
news:1ACC03C0-0EBD-4D90-A4EE-(E-Mail Removed)...
> Hello,
>
> I have a macro that runs and it ends up having to delete row 2 on 2
> different sheets, which I do with..... which I am only showing a portion
> to
> make it short and easy. This causes a problem is it causes my named range
> to
> have a #REF where it used to say $B$2.
>
> With .Worksheets("BO Ref List")
> .Range("A1").PasteSpecial
> .Columns("A:B").RemoveDuplicates Columns:=Array(1, 2),
> Header:=xlYes
> .Range("A2:B2").Delete Shift:=xlUp
>
> With .Worksheets("FO Ref List")
> .Range("A1").PasteSpecial
> .Columns("A:B").RemoveDuplicates Columns:=Array(1, 2),
> Header:=xlYes
> .Range("A2:B2").Delete Shift:=xlUp
>
> Here is the actual formula in my named range....
> BOAssociate "=OFFSET('BO Ref List'!$B$2,0,0,COUNTA('BO Ref
> List'!$B$2:$B$989),1)"
> FOAssociate "=OFFSET('FO Ref List'!$B$2,0,0,COUNTA('FO Ref
> List'!$B$2:$B$985),1)"
>
> I have attempted using a few different things, but I am drawing a blank
> when
> it comes to writing it into my macro to have it change the named range
> back
> to the above.
>
>



 
Reply With Quote
 
Brian
Guest
Posts: n/a
 
      13th Apr 2010
I was thinking too far into it and sometimes I just draw a blank. I knew it
was obvious, but I just couldnt think of it hehe.

"Bob Phillips" wrote:

>
> Why not just recreate it?
>
> .Names.Add Name:="BOAssociate", RefersTo:="=OFFSET('BO Ref
> List'!$B$2,0,0,COUNTA('BO Ref List'!$B$2:$B$989),1)"
>
> --
>
> HTH
>
> Bob
>
> "Brian" <(E-Mail Removed)> wrote in message
> news:1ACC03C0-0EBD-4D90-A4EE-(E-Mail Removed)...
> > Hello,
> >
> > I have a macro that runs and it ends up having to delete row 2 on 2
> > different sheets, which I do with..... which I am only showing a portion
> > to
> > make it short and easy. This causes a problem is it causes my named range
> > to
> > have a #REF where it used to say $B$2.
> >
> > With .Worksheets("BO Ref List")
> > .Range("A1").PasteSpecial
> > .Columns("A:B").RemoveDuplicates Columns:=Array(1, 2),
> > Header:=xlYes
> > .Range("A2:B2").Delete Shift:=xlUp
> >
> > With .Worksheets("FO Ref List")
> > .Range("A1").PasteSpecial
> > .Columns("A:B").RemoveDuplicates Columns:=Array(1, 2),
> > Header:=xlYes
> > .Range("A2:B2").Delete Shift:=xlUp
> >
> > Here is the actual formula in my named range....
> > BOAssociate "=OFFSET('BO Ref List'!$B$2,0,0,COUNTA('BO Ref
> > List'!$B$2:$B$989),1)"
> > FOAssociate "=OFFSET('FO Ref List'!$B$2,0,0,COUNTA('FO Ref
> > List'!$B$2:$B$985),1)"
> >
> > I have attempted using a few different things, but I am drawing a blank
> > when
> > it comes to writing it into my macro to have it change the named range
> > back
> > to the above.
> >
> >

>
>
> .
>

 
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
Named range in workseet code Dave Microsoft Excel Programming 8 21st Dec 2009 11:29 PM
VBA code to affect value of a named range Dave O Microsoft Excel Misc 5 25th Aug 2006 10:12 PM
Problem getting the value of a Named Range in code tbone Microsoft Excel Programming 1 21st Mar 2006 02:20 AM
Named Range Fails in VBA Code =?Utf-8?B?RGVhbiBIaW5zb24=?= Microsoft Excel Programming 3 24th Jan 2005 03:48 PM
Change named range value =?Utf-8?B?Sm9lIEJvdWNoZXI=?= Microsoft Excel Programming 2 30th Sep 2004 01:41 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:15 PM.