PC Review


Reply
Thread Tools Rate Thread

naming ranges in Excel2007 using VBA

 
 
c1802362
Guest
Posts: n/a
 
      14th May 2012
was recently "upgraded" from Win2000/MSO2003 to Win7/MSO2007

The following code written in Excel 2003 works in both Excel 2003 and
2007, but when I add code to a module in the exact same syntax in
Excel 2007, the system refuses to recognize it and doesn't flag me
there's an error.

The code:

' Name the range
Range("A1").CurrentRegion.Select ' select the range you want
named
ActiveWorkbook.Names.Add Name:="RangeName1", RefersToR1C1:=Selection

Any ideas as to why the system is acitng this way? Anysuggestions on
how to fix the problem?

Art
 
Reply With Quote
 
 
 
 
Don Guillett
Guest
Posts: n/a
 
      14th May 2012
On Monday, May 14, 2012 7:39:51 AM UTC-5, c1802362 wrote:
> was recently "upgraded" from Win2000/MSO2003 to Win7/MSO2007
>
> The following code written in Excel 2003 works in both Excel 2003 and
> 2007, but when I add code to a module in the exact same syntax in
> Excel 2007, the system refuses to recognize it and doesn't flag me
> there's an error.
>
> The code:
>
> ' Name the range
> Range("A1").CurrentRegion.Select ' select the range you want
> named
> ActiveWorkbook.Names.Add Name:="RangeName1", RefersToR1C1:=Selection
>
> Any ideas as to why the system is acitng this way? Anysuggestions on
> how to fix the problem?
>
> Art


You probably wanted tt but try my simpler version

Sub ttt()
ActiveSheet.UsedRange.Select
ActiveWorkbook.Names.Add Name:="RangeName1", _
RefersToR1C1:=Selection

End Sub
Sub nameit()
ActiveSheet.UsedRange.Name = "asusedrange"
ActiveSheet.Range("a1").CurrentRegion _
..Name = "a1curreg"

End Sub




 
Reply With Quote
 
 
 
 
c1802362
Guest
Posts: n/a
 
      14th May 2012

works for me .... Thanks!



On Monday, May 14, 2012 9:27:20 AM UTC-4, Don Guillett wrote:
> On Monday, May 14, 2012 7:39:51 AM UTC-5, c1802362 wrote:
> > was recently "upgraded" from Win2000/MSO2003 to Win7/MSO2007
> >
> > The following code written in Excel 2003 works in both Excel 2003 and
> > 2007, but when I add code to a module in the exact same syntax in
> > Excel 2007, the system refuses to recognize it and doesn't flag me
> > there's an error.
> >
> > The code:
> >
> > ' Name the range
> > Range("A1").CurrentRegion.Select ' select the range you want
> > named
> > ActiveWorkbook.Names.Add Name:="RangeName1", RefersToR1C1:=Selection
> >
> > Any ideas as to why the system is acitng this way? Anysuggestions on
> > how to fix the problem?
> >
> > Art

>
> You probably wanted tt but try my simpler version
>
> Sub ttt()
> ActiveSheet.UsedRange.Select
> ActiveWorkbook.Names.Add Name:="RangeName1", _
> RefersToR1C1:=Selection
>
> End Sub
> Sub nameit()
> ActiveSheet.UsedRange.Name = "asusedrange"
> ActiveSheet.Range("a1").CurrentRegion _
> .Name = "a1curreg"
>
> End Sub

 
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
does the "Range"object in excel2007 vba still have 65k row limit? Deniz Opal Microsoft Excel Programming 0 20th May 2008 04:17 PM
I can't open a VBA programed excel file in Excel2007?? =?Utf-8?B?TWF6?= Microsoft Excel Programming 3 19th Oct 2007 02:08 AM
Opening the VBA project in Excel2007 =?Utf-8?B?TWF6?= Microsoft Excel Crashes 1 17th Oct 2007 12:50 AM
VBA project opening problem in Excel2007 =?Utf-8?B?TWF6?= Microsoft Excel Misc 0 17th Oct 2007 12:39 AM
naming ranges with VBA jhahes Microsoft Excel Programming 3 10th Jun 2005 10:12 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:20 AM.