A Microsoft Excel forum. ExcelBanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » ExcelBanter forum » Excel Newsgroups » Excel Programming
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

naming ranges in Excel2007 using VBA



 
 
Thread Tools Display Modes
  #1  
Old May 14th 12, 01:39 PM posted to microsoft.public.excel.programming
c1802362[_2_]
external usenet poster
 
Posts: 60
Default naming ranges in Excel2007 using VBA

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
Ads
  #2  
Old May 14th 12, 02:27 PM posted to microsoft.public.excel.programming
Don Guillett[_2_]
external usenet poster
 
Posts: 1,506
Default naming ranges in Excel2007 using VBA

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




  #3  
Old May 14th 12, 04:40 PM posted to microsoft.public.excel.programming
c1802362[_2_]
external usenet poster
 
Posts: 60
Default naming ranges in Excel2007 using VBA


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

 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Naming ranges Amin Setting up and Configuration of Excel 1 April 25th 10 05:45 PM
Naming Ranges [email protected] Excel Programming 1 July 11th 07 07:49 AM
Naming Ranges PCLIVE Excel Programming 5 October 26th 06 09:26 PM
Naming ranges? pmw5 Excel Discussion (Misc queries) 2 March 4th 05 06:57 PM
naming ranges Alexander Bogomolny Excel Programming 2 July 28th 04 02:27 AM


All times are GMT +1. The time now is 03:19 AM.


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