PC Review


Reply
Thread Tools Rate Thread

Batch Naming of ranges

 
 
Andy Chan
Guest
Posts: n/a
 
      24th Dec 2005
Dear all,

There are 80 sheets in my workbook. I want to name the ranges A1:B20
with systematic names in these 80 sheets, say, student_01 for Sheet1!A1:B20,
student_02 for Sheet2!A1:B20, ..., student_80 for Sheet80!A1:B20. Can I name
these ranges easily? Thanks.

Best Regards,
Andy


 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      24th Dec 2005
Dim i As Long
For i = 1 To 80
Worksheets("Sheet" & i).Range("A1:B20").Name = "student_" &
Format(i, "00")
Next i


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Andy Chan" <chankhandy-(E-Mail Removed)> wrote in message
news:43ad162e$1@127.0.0.1...
> Dear all,
>
> There are 80 sheets in my workbook. I want to name the ranges A1:B20
> with systematic names in these 80 sheets, say, student_01 for

Sheet1!A1:B20,
> student_02 for Sheet2!A1:B20, ..., student_80 for Sheet80!A1:B20. Can I

name
> these ranges easily? Thanks.
>
> Best Regards,
> Andy
>
>



 
Reply With Quote
 
Niek Otten
Guest
Posts: n/a
 
      24th Dec 2005
Hi Andy,

Sub InsertNamedSheets()
Dim i As Long
For i = 1 To Worksheets.Count
ActiveWorkbook.Names.Add Name:="Student_" & Format(i, "00"),
RefersToR1C1:= _
"=Sheet" & i & "!R1C1:R20C1"
Next i
End Sub

If you're new to macros, look here first:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

--
Kind regards,

Niek Otten

"Andy Chan" <chankhandy-(E-Mail Removed)> wrote in message
news:43ad162e$1@127.0.0.1...
> Dear all,
>
> There are 80 sheets in my workbook. I want to name the ranges A1:B20
> with systematic names in these 80 sheets, say, student_01 for
> Sheet1!A1:B20, student_02 for Sheet2!A1:B20, ..., student_80 for
> Sheet80!A1:B20. Can I name these ranges easily? Thanks.
>
> Best Regards,
> Andy
>



 
Reply With Quote
 
Andy Chan
Guest
Posts: n/a
 
      24th Dec 2005
Thanks, it works!

"Bob Phillips" <(E-Mail Removed)> 撰寫於郵件新聞:(E-Mail Removed)...
> Dim i As Long
> For i = 1 To 80
> Worksheets("Sheet" & i).Range("A1:B20").Name = "student_" &
> Format(i, "00")
> Next i
>
>
> --
> HTH
>
> Bob Phillips
>
> (remove nothere from email address if mailing direct)
>
> "Andy Chan" <chankhandy-(E-Mail Removed)> wrote in message
> news:43ad162e$1@127.0.0.1...
>> Dear all,
>>
>> There are 80 sheets in my workbook. I want to name the ranges A1:B20
>> with systematic names in these 80 sheets, say, student_01 for

> Sheet1!A1:B20,
>> student_02 for Sheet2!A1:B20, ..., student_80 for Sheet80!A1:B20. Can I

> name
>> these ranges easily? Thanks.
>>
>> Best Regards,
>> Andy
>>
>>

>
>



 
Reply With Quote
 
Andy Chan
Guest
Posts: n/a
 
      24th Dec 2005
Thanks, it works!

"Niek Otten" <(E-Mail Removed)> 撰寫於郵件新聞:(E-Mail Removed)...
> Hi Andy,
>
> Sub InsertNamedSheets()
> Dim i As Long
> For i = 1 To Worksheets.Count
> ActiveWorkbook.Names.Add Name:="Student_" & Format(i, "00"),
> RefersToR1C1:= _
> "=Sheet" & i & "!R1C1:R20C1"
> Next i
> End Sub
>
> If you're new to macros, look here first:
>
> http://www.mvps.org/dmcritchie/excel/getstarted.htm
>
> --
> Kind regards,
>
> Niek Otten
>
> "Andy Chan" <chankhandy-(E-Mail Removed)> wrote in message
> news:43ad162e$1@127.0.0.1...
>> Dear all,
>>
>> There are 80 sheets in my workbook. I want to name the ranges A1:B20
>> with systematic names in these 80 sheets, say, student_01 for
>> Sheet1!A1:B20, student_02 for Sheet2!A1:B20, ..., student_80 for
>> Sheet80!A1:B20. Can I name these ranges easily? Thanks.
>>
>> Best Regards,
>> Andy
>>

>
>



 
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
Naming Ranges PCLIVE Microsoft Excel Programming 5 26th Oct 2006 09:26 PM
Naming ranges? =?Utf-8?B?cG13NQ==?= Microsoft Excel Misc 2 4th Mar 2005 06:57 PM
Naming Ranges =?Utf-8?B?U2ltb24gU2hhdw==?= Microsoft Excel Misc 1 15th Feb 2005 01:17 AM
naming ranges Alexander Bogomolny Microsoft Excel Programming 2 28th Jul 2004 02:27 AM
Naming ranges Mike B Microsoft Excel Worksheet Functions 2 5th Aug 2003 10:35 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:22 PM.