Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 69
Default trying to create sheets and tab names from first colum of data

I have a DB result sheet, now I am trying to create worksheets for each
individual customer number in the first column of my datasheet and give the
tab of that worksheet the customer number.

I am using this but it doesnt seem to be working


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

what I am looking for it to do is go through my rawdata in column A and
create a worksheet (giving the tab the name of the cusotmer number), I also
wanted this to skip existing customer numbers where a sheet already exists
and move on till its done.

Any thoughts?

Thanks in advance


--
Nelson
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default trying to create sheets and tab names from first colum of data

Try this

Option Explicit

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

Dim myWS As Excel.Worksheet
Dim WS As Excel.Worksheet
Dim myWB As Excel.Workbook

Set myWB = ThisWorkbook

Set myWS = Worksheet("RawData")

Set MyRange = myWS.Range("L:L")
Set MyRange = Range(MyRange, MyRange.End(xlDown))

For Each MyCell In MyRange
Set myWS = Nothing
On Error Resume Next
Set myWS = myWB.Worksheets(MyCell.Value)
On Error GoTo 0

If myWS Is Nothing Then
Set myWS = Worksheet.Add(After:=Worksheet(Sheets.Count)) 'creates a
new worksheet
myWS.Name = MyCell.Value ' renames the new worksheet
End If
Next MyCell
End Sub

HTH,
Barb Reinhardt

"Nelson" wrote:

I have a DB result sheet, now I am trying to create worksheets for each
individual customer number in the first column of my datasheet and give the
tab of that worksheet the customer number.

I am using this but it doesnt seem to be working


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

what I am looking for it to do is go through my rawdata in column A and
create a worksheet (giving the tab the name of the cusotmer number), I also
wanted this to skip existing customer numbers where a sheet already exists
and move on till its done.

Any thoughts?

Thanks in advance


--
Nelson

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 69
Default trying to create sheets and tab names from first colum of data

Thanks, but I am getting a subfunction not defined on workbook?

What am I missing?

Thanks

--
Nelson


"Barb Reinhardt" wrote:

Try this

Option Explicit

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

Dim myWS As Excel.Worksheet
Dim WS As Excel.Worksheet
Dim myWB As Excel.Workbook

Set myWB = ThisWorkbook

Set myWS = Worksheet("RawData")

Set MyRange = myWS.Range("L:L")
Set MyRange = Range(MyRange, MyRange.End(xlDown))

For Each MyCell In MyRange
Set myWS = Nothing
On Error Resume Next
Set myWS = myWB.Worksheets(MyCell.Value)
On Error GoTo 0

If myWS Is Nothing Then
Set myWS = Worksheet.Add(After:=Worksheet(Sheets.Count)) 'creates a
new worksheet
myWS.Name = MyCell.Value ' renames the new worksheet
End If
Next MyCell
End Sub

HTH,
Barb Reinhardt

"Nelson" wrote:

I have a DB result sheet, now I am trying to create worksheets for each
individual customer number in the first column of my datasheet and give the
tab of that worksheet the customer number.

I am using this but it doesnt seem to be working


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

what I am looking for it to do is go through my rawdata in column A and
create a worksheet (giving the tab the name of the cusotmer number), I also
wanted this to skip existing customer numbers where a sheet already exists
and move on till its done.

Any thoughts?

Thanks in advance


--
Nelson

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
trying to create sheets and tab names from first colum of data Ron de Bruin Excel Programming 0 June 11th 09 07:12 PM
Multiple Sheets (Need to create 500 individual sheets in one workbook, pulling DATA Amaxwell Excel Worksheet Functions 4 August 17th 06 06:23 AM
Keeping a sum colum correct after inserting a colum of data in fro hazel Excel Discussion (Misc queries) 3 October 19th 05 09:51 PM
Look up data in colum a and find match in colum b Chris(new user) Excel Discussion (Misc queries) 1 March 22nd 05 01:41 PM
Check data on colum A and find match on colum b Chris(new user) Excel Discussion (Misc queries) 3 March 20th 05 04:45 PM


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

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

About Us

"It's about Microsoft Excel"