PC Review


Reply
Thread Tools Rate Thread

creat sheets with assigned name and protected

 
 
Dennis Cheung
Guest
Posts: n/a
 
      20th Nov 2009
dear masters,

in sheet 1, cell a1 to a100 contents are
a1 abc
a2 bcd
a3 cde
a4 to a100 are blank
i need a marco to creat sheets with names according to contents in a1 to
a100. no sheet will be created if the cell is empty.
then those newly created sheets are protect by password "123456".
can i do that?

thanks in advance.
--
Dennis Cheung
 
Reply With Quote
 
 
 
 
Sam Wilson
Guest
Posts: n/a
 
      20th Nov 2009
Sub test()

Dim i As Integer
Dim xws As Worksheet
Dim ws As Worksheet

Set xws = ActiveSheet

For i = 0 To 99
If Not IsEmpty(xws.Range("A1").Offset(i, 0)) Then
Set ws = Worksheets.Add
ws.Name = xws.Range("A1").Offset(i, 0).Value
ws.Protect "123456"
End If
Next i

End Sub


"Dennis Cheung" wrote:

> dear masters,
>
> in sheet 1, cell a1 to a100 contents are
> a1 abc
> a2 bcd
> a3 cde
> a4 to a100 are blank
> i need a marco to creat sheets with names according to contents in a1 to
> a100. no sheet will be created if the cell is empty.
> then those newly created sheets are protect by password "123456".
> can i do that?
>
> thanks in advance.
> --
> Dennis Cheung

 
Reply With Quote
 
Dennis Cheung
Guest
Posts: n/a
 
      20th Nov 2009
Dear Sam,

Thanks for your help, it works good.

can i make those new sheets are created after sheet 1, and they are in order
from a1 to a100. the code you send me created sheets in order of backward.
--
Dennis Cheung


"Sam Wilson" wrote:

> Sub test()
>
> Dim i As Integer
> Dim xws As Worksheet
> Dim ws As Worksheet
>
> Set xws = ActiveSheet
>
> For i = 0 To 99
> If Not IsEmpty(xws.Range("A1").Offset(i, 0)) Then
> Set ws = Worksheets.Add
> ws.Name = xws.Range("A1").Offset(i, 0).Value
> ws.Protect "123456"
> End If
> Next i
>
> End Sub
>
>
> "Dennis Cheung" wrote:
>
> > dear masters,
> >
> > in sheet 1, cell a1 to a100 contents are
> > a1 abc
> > a2 bcd
> > a3 cde
> > a4 to a100 are blank
> > i need a marco to creat sheets with names according to contents in a1 to
> > a100. no sheet will be created if the cell is empty.
> > then those newly created sheets are protect by password "123456".
> > can i do that?
> >
> > thanks in advance.
> > --
> > Dennis Cheung

 
Reply With Quote
 
Sam Wilson
Guest
Posts: n/a
 
      20th Nov 2009
Yes, several ways...

Change

For i = 0 To 99

to

For i = 99 To 0 step -1

being one.

Sam

"Dennis Cheung" wrote:

> Dear Sam,
>
> Thanks for your help, it works good.
>
> can i make those new sheets are created after sheet 1, and they are in order
> from a1 to a100. the code you send me created sheets in order of backward.
> --
> Dennis Cheung
>
>
> "Sam Wilson" wrote:
>
> > Sub test()
> >
> > Dim i As Integer
> > Dim xws As Worksheet
> > Dim ws As Worksheet
> >
> > Set xws = ActiveSheet
> >
> > For i = 0 To 99
> > If Not IsEmpty(xws.Range("A1").Offset(i, 0)) Then
> > Set ws = Worksheets.Add
> > ws.Name = xws.Range("A1").Offset(i, 0).Value
> > ws.Protect "123456"
> > End If
> > Next i
> >
> > End Sub
> >
> >
> > "Dennis Cheung" wrote:
> >
> > > dear masters,
> > >
> > > in sheet 1, cell a1 to a100 contents are
> > > a1 abc
> > > a2 bcd
> > > a3 cde
> > > a4 to a100 are blank
> > > i need a marco to creat sheets with names according to contents in a1 to
> > > a100. no sheet will be created if the cell is empty.
> > > then those newly created sheets are protect by password "123456".
> > > can i do that?
> > >
> > > thanks in advance.
> > > --
> > > Dennis Cheung

 
Reply With Quote
 
Dennis Cheung
Guest
Posts: n/a
 
      22nd Nov 2009
dear sam,

it works the same as before. any other way?
--
Dennis Cheung


"Sam Wilson" wrote:

> Yes, several ways...
>
> Change
>
> For i = 0 To 99
>
> to
>
> For i = 99 To 0 step -1
>
> being one.
>
> Sam
>
> "Dennis Cheung" wrote:
>
> > Dear Sam,
> >
> > Thanks for your help, it works good.
> >
> > can i make those new sheets are created after sheet 1, and they are in order
> > from a1 to a100. the code you send me created sheets in order of backward.
> > --
> > Dennis Cheung
> >
> >
> > "Sam Wilson" wrote:
> >
> > > Sub test()
> > >
> > > Dim i As Integer
> > > Dim xws As Worksheet
> > > Dim ws As Worksheet
> > >
> > > Set xws = ActiveSheet
> > >
> > > For i = 0 To 99
> > > If Not IsEmpty(xws.Range("A1").Offset(i, 0)) Then
> > > Set ws = Worksheets.Add
> > > ws.Name = xws.Range("A1").Offset(i, 0).Value
> > > ws.Protect "123456"
> > > End If
> > > Next i
> > >
> > > End Sub
> > >
> > >
> > > "Dennis Cheung" wrote:
> > >
> > > > dear masters,
> > > >
> > > > in sheet 1, cell a1 to a100 contents are
> > > > a1 abc
> > > > a2 bcd
> > > > a3 cde
> > > > a4 to a100 are blank
> > > > i need a marco to creat sheets with names according to contents in a1 to
> > > > a100. no sheet will be created if the cell is empty.
> > > > then those newly created sheets are protect by password "123456".
> > > > can i do that?
> > > >
> > > > thanks in advance.
> > > > --
> > > > Dennis Cheung

 
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
Grouping with protected sheets (multiple sheets) Krista Microsoft Excel Misc 0 28th Oct 2009 01:28 PM
Macro for filter on protected workbook that works for all sheets, no matter what sheets are named? StargateFanFromWork Microsoft Excel Programming 6 26th Jan 2006 06:31 PM
I want to creat automatically new work sheets Babar Microsoft Excel Worksheet Functions 0 14th Dec 2005 04:40 AM
How can I creat a combined sheet using the data in other sheets? =?Utf-8?B?YXJiaW4=?= Microsoft Excel Misc 1 18th Aug 2004 12:54 PM
Macro (assigned to button) doens't work when sheet is protected Deb Microsoft Excel Worksheet Functions 1 16th Jul 2003 04:55 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:00 PM.