PC Review


Reply
Thread Tools Rate Thread

Create tabs against main list, now I need errors

 
 
Neall
Guest
Posts: n/a
 
      8th Jun 2009
Good day, I have created the following button that will search against my
list of customers and create a tab based on their customer number

Private Sub CreateSheetsFromAList()
Dim MyCell As Range, MyRange As Range

Set MyRange = Sheets("RawData").Range("RawData!L:L")
Set MyRange = Range(MyRange, MyRange.End(xlDown))

For Each MyCell In MyRange
Sheets.Add After:=Sheets(Sheets.Count) 'creates a new worksheet
Sheets(Sheets.Count).Name = MyCell.Value ' renames the new worksheet
Next MyCell
End Sub

Now I need to add 2 more options that I am not sure how to add.
1. add an error out option that if a tab already exists to skip creating
that tab and move on

2. I would like to get a summary in a box back of the name and customer
number that were just created in that update so I can go and take a look at
that customer.

Any suggestions?

Thanks in advance

Neall






--
Neall
 
Reply With Quote
 
 
 
 
Joel
Guest
Posts: n/a
 
      8th Jun 2009
I colored each cell in Myrange the color green. Then went through each sheet
and if the sheet name was in MyRange I removed the color. The cells that
were colored are the new customers. I then went back through each cell in
Myrange and the cells that were colored I added new sheets.

Private Sub CreateSheetsFromAList()
Dim MyCell As Range, MyRange As Range

Set MyRange = Sheets("RawData").Range("RawData!L:L")
Set MyRange = Range(MyRange, MyRange.End(xlDown))

MyRange.Interior.ColorIndex = 4 'color every cell Green

'turn off the color if the sheet exists
For Each sht In Sheets
Set c = MyRange.Find(what:=sht.Name, _
LookIn:=xlValues, lookat:=xlWhole)
If Not c Is Nothing Then
c.Interior.ColorIndex = xlNone
End If
Next sht

'add new sheet for the items that are colored
For Each MyCell In MyRange
If MyCell.Interior.ColorIndex <> xlNone Then
Sheets.Add After:=Sheets(Sheets.Count) 'creates a new worksheet
Sheets(Sheets.Count).Name = MyCell.Value ' renames the new worksheet
End If
Next MyCell
End Sub


"Neall" wrote:

> Good day, I have created the following button that will search against my
> list of customers and create a tab based on their customer number
>
> Private Sub CreateSheetsFromAList()
> Dim MyCell As Range, MyRange As Range
>
> Set MyRange = Sheets("RawData").Range("RawData!L:L")
> Set MyRange = Range(MyRange, MyRange.End(xlDown))
>
> For Each MyCell In MyRange
> Sheets.Add After:=Sheets(Sheets.Count) 'creates a new worksheet
> Sheets(Sheets.Count).Name = MyCell.Value ' renames the new worksheet
> Next MyCell
> End Sub
>
> Now I need to add 2 more options that I am not sure how to add.
> 1. add an error out option that if a tab already exists to skip creating
> that tab and move on
>
> 2. I would like to get a summary in a box back of the name and customer
> number that were just created in that update so I can go and take a look at
> that customer.
>
> Any suggestions?
>
> Thanks in advance
>
> Neall
>
>
>
>
>
>
> --
> Neall

 
Reply With Quote
 
Neall
Guest
Posts: n/a
 
      8th Jun 2009
Thanks, I am getting a application defined out of range error when trying to
move beyond this point

Set MyRange = Range(MyRange, MyRange.End(xlDown))

Any idea's?
--
Neall


"Joel" wrote:

> I colored each cell in Myrange the color green. Then went through each sheet
> and if the sheet name was in MyRange I removed the color. The cells that
> were colored are the new customers. I then went back through each cell in
> Myrange and the cells that were colored I added new sheets.
>
> Private Sub CreateSheetsFromAList()
> Dim MyCell As Range, MyRange As Range
>
> Set MyRange = Sheets("RawData").Range("RawData!L:L")
> Set MyRange = Range(MyRange, MyRange.End(xlDown))
>
> MyRange.Interior.ColorIndex = 4 'color every cell Green
>
> 'turn off the color if the sheet exists
> For Each sht In Sheets
> Set c = MyRange.Find(what:=sht.Name, _
> LookIn:=xlValues, lookat:=xlWhole)
> If Not c Is Nothing Then
> c.Interior.ColorIndex = xlNone
> End If
> Next sht
>
> 'add new sheet for the items that are colored
> For Each MyCell In MyRange
> If MyCell.Interior.ColorIndex <> xlNone Then
> Sheets.Add After:=Sheets(Sheets.Count) 'creates a new worksheet
> Sheets(Sheets.Count).Name = MyCell.Value ' renames the new worksheet
> End If
> Next MyCell
> End Sub
>
>
> "Neall" wrote:
>
> > Good day, I have created the following button that will search against my
> > list of customers and create a tab based on their customer number
> >
> > Private Sub CreateSheetsFromAList()
> > Dim MyCell As Range, MyRange As Range
> >
> > Set MyRange = Sheets("RawData").Range("RawData!L:L")
> > Set MyRange = Range(MyRange, MyRange.End(xlDown))
> >
> > For Each MyCell In MyRange
> > Sheets.Add After:=Sheets(Sheets.Count) 'creates a new worksheet
> > Sheets(Sheets.Count).Name = MyCell.Value ' renames the new worksheet
> > Next MyCell
> > End Sub
> >
> > Now I need to add 2 more options that I am not sure how to add.
> > 1. add an error out option that if a tab already exists to skip creating
> > that tab and move on
> >
> > 2. I would like to get a summary in a box back of the name and customer
> > number that were just created in that update so I can go and take a look at
> > that customer.
> >
> > Any suggestions?
> >
> > Thanks in advance
> >
> > Neall
> >
> >
> >
> >
> >
> >
> > --
> > Neall

 
Reply With Quote
 
Joel
Guest
Posts: n/a
 
      8th Jun 2009
You weren't specifying the sheet. I made a slight change. I didn't get the
error when I tested the code.

Private Sub CreateSheetsFromAList()
Dim MyCell As Range, MyRange As Range

With Sheets("RawData")
Set MyRange = .Range("L1")
Set MyRange = .Range(MyRange, MyRange.End(xlDown))
End With

MyRange.Interior.ColorIndex = 4 'color every cell Green

'turn off the color if the sheet exists
For Each sht In Sheets
Set c = MyRange.Find(what:=sht.Name, _
LookIn:=xlValues, lookat:=xlWhole)
If Not c Is Nothing Then
c.Interior.ColorIndex = xlNone
End If
Next sht

'add new sheet for the items that are colored
For Each MyCell In MyRange
If MyCell.Interior.ColorIndex <> xlNone Then
Sheets.Add After:=Sheets(Sheets.Count) 'creates a new worksheet
Sheets(Sheets.Count).Name = MyCell.Value ' renames the new worksheet
End If
Next MyCell
End Sub


"Neall" wrote:

> Thanks, I am getting a application defined out of range error when trying to
> move beyond this point
>
> Set MyRange = Range(MyRange, MyRange.End(xlDown))
>
> Any idea's?
> --
> Neall
>
>
> "Joel" wrote:
>
> > I colored each cell in Myrange the color green. Then went through each sheet
> > and if the sheet name was in MyRange I removed the color. The cells that
> > were colored are the new customers. I then went back through each cell in
> > Myrange and the cells that were colored I added new sheets.
> >
> > Private Sub CreateSheetsFromAList()
> > Dim MyCell As Range, MyRange As Range
> >
> > Set MyRange = Sheets("RawData").Range("RawData!L:L")
> > Set MyRange = Range(MyRange, MyRange.End(xlDown))
> >
> > MyRange.Interior.ColorIndex = 4 'color every cell Green
> >
> > 'turn off the color if the sheet exists
> > For Each sht In Sheets
> > Set c = MyRange.Find(what:=sht.Name, _
> > LookIn:=xlValues, lookat:=xlWhole)
> > If Not c Is Nothing Then
> > c.Interior.ColorIndex = xlNone
> > End If
> > Next sht
> >
> > 'add new sheet for the items that are colored
> > For Each MyCell In MyRange
> > If MyCell.Interior.ColorIndex <> xlNone Then
> > Sheets.Add After:=Sheets(Sheets.Count) 'creates a new worksheet
> > Sheets(Sheets.Count).Name = MyCell.Value ' renames the new worksheet
> > End If
> > Next MyCell
> > End Sub
> >
> >
> > "Neall" wrote:
> >
> > > Good day, I have created the following button that will search against my
> > > list of customers and create a tab based on their customer number
> > >
> > > Private Sub CreateSheetsFromAList()
> > > Dim MyCell As Range, MyRange As Range
> > >
> > > Set MyRange = Sheets("RawData").Range("RawData!L:L")
> > > Set MyRange = Range(MyRange, MyRange.End(xlDown))
> > >
> > > For Each MyCell In MyRange
> > > Sheets.Add After:=Sheets(Sheets.Count) 'creates a new worksheet
> > > Sheets(Sheets.Count).Name = MyCell.Value ' renames the new worksheet
> > > Next MyCell
> > > End Sub
> > >
> > > Now I need to add 2 more options that I am not sure how to add.
> > > 1. add an error out option that if a tab already exists to skip creating
> > > that tab and move on
> > >
> > > 2. I would like to get a summary in a box back of the name and customer
> > > number that were just created in that update so I can go and take a look at
> > > that customer.
> > >
> > > Any suggestions?
> > >
> > > Thanks in advance
> > >
> > > Neall
> > >
> > >
> > >
> > >
> > >
> > >
> > > --
> > > Neall

 
Reply With Quote
 
 
 
Reply

« Re: macro | macro »
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
Create a list of pre-named tabs darsh Microsoft Excel Programming 2 18th Mar 2010 03:09 AM
Using worksheet template create tabs against customer list Neall Microsoft Excel Worksheet Functions 0 4th Jun 2009 07:03 PM
How do I create a list (Word) of the names on Excel worksheet tabs =?Utf-8?B?UFQ=?= Microsoft Excel Worksheet Functions 3 23rd Feb 2007 05:24 PM
Re: How can Excel create a list of tabs on a worksheet? Paul B Microsoft Excel Misc 0 14th Apr 2005 02:46 PM
Create Sheet Tabs from the List (URGENT) Murtaza Microsoft Excel Discussion 12 22nd Sep 2003 10:02 AM


Features
 

Advertising
 

Newsgroups
 


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