Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default Auto Create workbooks and worksheets per columnar data

I have a list of data below. I need to create a unique workbook for every
unique name, while creating the worksheets in column A assigned to that
workbook in column B.
For example, the data below says that I will have one workbook named Alan
Groby. Inside of that workbook there will be two worksheets; one named
Import/Export Compliance and the other Video Conferencing. I have verified
that all column A data is correct symbols and length for worksheet names.
Then I am looking now but I will need to copy a source worksheet data into
each worksheet in every workbook. Basically this will a template for each
worksheet; it just has some colors and stuff that is it. But my main goal is
to get workbook and worksheets created ASAP. Thank you

Column A Column B
Import/Export Compliance Alan Grobey
Video Conferencing Alan Grobey
Disaster Recovery Proposal Anne Elledge
Upholstery Move Anthony Glathar
Trade Show Booth Bill Staser
Dental Furniture Special Bill Stewart
Cuspidor Replacement Prgm Bruno Zadnik
Raw material callout on dwgs Bruno Zadnik

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Auto Create workbooks and worksheets per columnar data

Try something like this:

Sub NewList()
Dim rng As Range, cell As Range
Dim startrow As Long, sh As Worksheet
Dim bk as Workbook, startrow as Long
startrow = 2

With Worksheets("Sheet1")
Set rng = .Range(.Cells(startrow, 2), _
.Cells(startrow, 2).End(xlDown))
End With
For Each cell In rng
if cell.value < cell.offset(-1,0) then
if not bk is Nothing then _
bk.Close Savechange:=True
set bk = workbooks.Add(Template:=xlWBATWorksheet)
bk.worksheets(1).Name = cell.offset(0,-1).Value

' Change path in the next line

bk.SaveAs "c:\Myfolder\" & cell.Value & ".xls"
else
bk.Add After:=bk.Worksheets(bk.Worksheets.count)
activesheet.Name = cell.offset(0,-1)
end if
Next
if not bk is nothing then _
bk.Close Savechanges:=True
End Sub

--
Regards,
Tom Ogilvy


"Rookie_User" wrote:

I have a list of data below. I need to create a unique workbook for every
unique name, while creating the worksheets in column A assigned to that
workbook in column B.
For example, the data below says that I will have one workbook named Alan
Groby. Inside of that workbook there will be two worksheets; one named
Import/Export Compliance and the other Video Conferencing. I have verified
that all column A data is correct symbols and length for worksheet names.
Then I am looking now but I will need to copy a source worksheet data into
each worksheet in every workbook. Basically this will a template for each
worksheet; it just has some colors and stuff that is it. But my main goal is
to get workbook and worksheets created ASAP. Thank you

Column A Column B
Import/Export Compliance Alan Grobey
Video Conferencing Alan Grobey
Disaster Recovery Proposal Anne Elledge
Upholstery Move Anthony Glathar
Trade Show Booth Bill Staser
Dental Furniture Special Bill Stewart
Cuspidor Replacement Prgm Bruno Zadnik
Raw material callout on dwgs Bruno Zadnik

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default Auto Create workbooks and worksheets per columnar data

I get an error on compile because of the workbook code.

It says duplicate already.....
Dim bk as Workbook, startrow as Long


Then when I remove from the ,--- I then get an error
Named argument not found and highlights the saved:= area

Any advice?

"Tom Ogilvy" wrote:

Try something like this:

Sub NewList()
Dim rng As Range, cell As Range
Dim startrow As Long, sh As Worksheet
Dim bk as Workbook, startrow as Long
startrow = 2

With Worksheets("Sheet1")
Set rng = .Range(.Cells(startrow, 2), _
.Cells(startrow, 2).End(xlDown))
End With
For Each cell In rng
if cell.value < cell.offset(-1,0) then
if not bk is Nothing then _
bk.Close Savechange:=True
set bk = workbooks.Add(Template:=xlWBATWorksheet)
bk.worksheets(1).Name = cell.offset(0,-1).Value

' Change path in the next line

bk.SaveAs "c:\Myfolder\" & cell.Value & ".xls"
else
bk.Add After:=bk.Worksheets(bk.Worksheets.count)
activesheet.Name = cell.offset(0,-1)
end if
Next
if not bk is nothing then _
bk.Close Savechanges:=True
End Sub

--
Regards,
Tom Ogilvy


"Rookie_User" wrote:

I have a list of data below. I need to create a unique workbook for every
unique name, while creating the worksheets in column A assigned to that
workbook in column B.
For example, the data below says that I will have one workbook named Alan
Groby. Inside of that workbook there will be two worksheets; one named
Import/Export Compliance and the other Video Conferencing. I have verified
that all column A data is correct symbols and length for worksheet names.
Then I am looking now but I will need to copy a source worksheet data into
each worksheet in every workbook. Basically this will a template for each
worksheet; it just has some colors and stuff that is it. But my main goal is
to get workbook and worksheets created ASAP. Thank you

Column A Column B
Import/Export Compliance Alan Grobey
Video Conferencing Alan Grobey
Disaster Recovery Proposal Anne Elledge
Upholstery Move Anthony Glathar
Trade Show Booth Bill Staser
Dental Furniture Special Bill Stewart
Cuspidor Replacement Prgm Bruno Zadnik
Raw material callout on dwgs Bruno Zadnik

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default Auto Create workbooks and worksheets per columnar data

I think I fixed the issues but as I added the "s" to the savechanges:=true it
worked. But then I get an application defined or object defined error and I
don't know where to go from here. Thanks Tom for your time.

"Tom Ogilvy" wrote:

Try something like this:

Sub NewList()
Dim rng As Range, cell As Range
Dim startrow As Long, sh As Worksheet
Dim bk as Workbook, startrow as Long
startrow = 2

With Worksheets("Sheet1")
Set rng = .Range(.Cells(startrow, 2), _
.Cells(startrow, 2).End(xlDown))
End With
For Each cell In rng
if cell.value < cell.offset(-1,0) then
if not bk is Nothing then _
bk.Close Savechange:=True
set bk = workbooks.Add(Template:=xlWBATWorksheet)
bk.worksheets(1).Name = cell.offset(0,-1).Value

' Change path in the next line

bk.SaveAs "c:\Myfolder\" & cell.Value & ".xls"
else
bk.Add After:=bk.Worksheets(bk.Worksheets.count)
activesheet.Name = cell.offset(0,-1)
end if
Next
if not bk is nothing then _
bk.Close Savechanges:=True
End Sub

--
Regards,
Tom Ogilvy


"Rookie_User" wrote:

I have a list of data below. I need to create a unique workbook for every
unique name, while creating the worksheets in column A assigned to that
workbook in column B.
For example, the data below says that I will have one workbook named Alan
Groby. Inside of that workbook there will be two worksheets; one named
Import/Export Compliance and the other Video Conferencing. I have verified
that all column A data is correct symbols and length for worksheet names.
Then I am looking now but I will need to copy a source worksheet data into
each worksheet in every workbook. Basically this will a template for each
worksheet; it just has some colors and stuff that is it. But my main goal is
to get workbook and worksheets created ASAP. Thank you

Column A Column B
Import/Export Compliance Alan Grobey
Video Conferencing Alan Grobey
Disaster Recovery Proposal Anne Elledge
Upholstery Move Anthony Glathar
Trade Show Booth Bill Staser
Dental Furniture Special Bill Stewart
Cuspidor Replacement Prgm Bruno Zadnik
Raw material callout on dwgs Bruno Zadnik

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default Auto Create workbooks and worksheets per columnar data

IT works except this last piece.

bk.Add After:=bk.Worksheets(bk.Worksheets.Count)

It says teh "Add" part is not real or correct or something like that?

"Tom Ogilvy" wrote:

Try something like this:

Sub NewList()
Dim rng As Range, cell As Range
Dim startrow As Long, sh As Worksheet
Dim bk as Workbook, startrow as Long
startrow = 2

With Worksheets("Sheet1")
Set rng = .Range(.Cells(startrow, 2), _
.Cells(startrow, 2).End(xlDown))
End With
For Each cell In rng
if cell.value < cell.offset(-1,0) then
if not bk is Nothing then _
bk.Close Savechange:=True
set bk = workbooks.Add(Template:=xlWBATWorksheet)
bk.worksheets(1).Name = cell.offset(0,-1).Value

' Change path in the next line

bk.SaveAs "c:\Myfolder\" & cell.Value & ".xls"
else
bk.Add After:=bk.Worksheets(bk.Worksheets.count)
activesheet.Name = cell.offset(0,-1)
end if
Next
if not bk is nothing then _
bk.Close Savechanges:=True
End Sub

--
Regards,
Tom Ogilvy


"Rookie_User" wrote:

I have a list of data below. I need to create a unique workbook for every
unique name, while creating the worksheets in column A assigned to that
workbook in column B.
For example, the data below says that I will have one workbook named Alan
Groby. Inside of that workbook there will be two worksheets; one named
Import/Export Compliance and the other Video Conferencing. I have verified
that all column A data is correct symbols and length for worksheet names.
Then I am looking now but I will need to copy a source worksheet data into
each worksheet in every workbook. Basically this will a template for each
worksheet; it just has some colors and stuff that is it. But my main goal is
to get workbook and worksheets created ASAP. Thank you

Column A Column B
Import/Export Compliance Alan Grobey
Video Conferencing Alan Grobey
Disaster Recovery Proposal Anne Elledge
Upholstery Move Anthony Glathar
Trade Show Booth Bill Staser
Dental Furniture Special Bill Stewart
Cuspidor Replacement Prgm Bruno Zadnik
Raw material callout on dwgs Bruno Zadnik



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Auto Create workbooks and worksheets per columnar data

You are right. The object "bk", which is a workbook,
needs some property referring to a worksheet.
Therefor, please do replace the wrong statement:
bk.Add After:=bk.Worksheets(bk.Worksheets.count)
with the right statement:
bk.worksheets.Add After:=bk.Worksheets(bk.Worksheets.count)
Briefly, you have the write the word 'worksheets' between the words 'bk' and
'add'

"Rookie_User" wrote:

IT works except this last piece.

bk.Add After:=bk.Worksheets(bk.Worksheets.Count)

It says teh "Add" part is not real or correct or something like that?

"Tom Ogilvy" wrote:

Try something like this:

Sub NewList()
Dim rng As Range, cell As Range
Dim startrow As Long, sh As Worksheet
Dim bk as Workbook, startrow as Long
startrow = 2

With Worksheets("Sheet1")
Set rng = .Range(.Cells(startrow, 2), _
.Cells(startrow, 2).End(xlDown))
End With
For Each cell In rng
if cell.value < cell.offset(-1,0) then
if not bk is Nothing then _
bk.Close Savechange:=True
set bk = workbooks.Add(Template:=xlWBATWorksheet)
bk.worksheets(1).Name = cell.offset(0,-1).Value

' Change path in the next line

bk.SaveAs "c:\Myfolder\" & cell.Value & ".xls"
else
bk.Add After:=bk.Worksheets(bk.Worksheets.count)
activesheet.Name = cell.offset(0,-1)
end if
Next
if not bk is nothing then _
bk.Close Savechanges:=True
End Sub

--
Regards,
Tom Ogilvy


"Rookie_User" wrote:

I have a list of data below. I need to create a unique workbook for every
unique name, while creating the worksheets in column A assigned to that
workbook in column B.
For example, the data below says that I will have one workbook named Alan
Groby. Inside of that workbook there will be two worksheets; one named
Import/Export Compliance and the other Video Conferencing. I have verified
that all column A data is correct symbols and length for worksheet names.
Then I am looking now but I will need to copy a source worksheet data into
each worksheet in every workbook. Basically this will a template for each
worksheet; it just has some colors and stuff that is it. But my main goal is
to get workbook and worksheets created ASAP. Thank you

Column A Column B
Import/Export Compliance Alan Grobey
Video Conferencing Alan Grobey
Disaster Recovery Proposal Anne Elledge
Upholstery Move Anthony Glathar
Trade Show Booth Bill Staser
Dental Furniture Special Bill Stewart
Cuspidor Replacement Prgm Bruno Zadnik
Raw material callout on dwgs Bruno Zadnik

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Auto Create workbooks and worksheets per columnar data

Sub NewList()
Dim rng As Range, cell As Range
Dim sh As Worksheet
Dim bk as Workbook, startrow as Long
startrow = 2

With Worksheets("Sheet1")
Set rng = .Range(.Cells(startrow, 2), _
.Cells(startrow, 2).End(xlDown))
End With
For Each cell In rng
if cell.value < cell.offset(-1,0) then
if not bk is Nothing then _
bk.Close Savechanges:=True
set bk = workbooks.Add(Template:=xlWBATWorksheet)
bk.worksheets(1).Name = cell.offset(0,-1).Value

' Change path in the next line

bk.SaveAs "c:\Myfolder\" & cell.Value & ".xls"
else
bk.Worksheets.Add After:=bk.Worksheets(bk.Worksheets.count)
activesheet.Name = cell.offset(0,-1)
end if
Next
if not bk is nothing then _
bk.Close Savechanges:=True
End Sub

--
Regards,
Tom Ogilvy

"Rookie_User" wrote:

IT works except this last piece.

bk.Add After:=bk.Worksheets(bk.Worksheets.Count)

It says teh "Add" part is not real or correct or something like that?

"Tom Ogilvy" wrote:

Try something like this:

Sub NewList()
Dim rng As Range, cell As Range
Dim startrow As Long, sh As Worksheet
Dim bk as Workbook, startrow as Long
startrow = 2

With Worksheets("Sheet1")
Set rng = .Range(.Cells(startrow, 2), _
.Cells(startrow, 2).End(xlDown))
End With
For Each cell In rng
if cell.value < cell.offset(-1,0) then
if not bk is Nothing then _
bk.Close Savechange:=True
set bk = workbooks.Add(Template:=xlWBATWorksheet)
bk.worksheets(1).Name = cell.offset(0,-1).Value

' Change path in the next line

bk.SaveAs "c:\Myfolder\" & cell.Value & ".xls"
else
bk.Add After:=bk.Worksheets(bk.Worksheets.count)
activesheet.Name = cell.offset(0,-1)
end if
Next
if not bk is nothing then _
bk.Close Savechanges:=True
End Sub

--
Regards,
Tom Ogilvy


"Rookie_User" wrote:

I have a list of data below. I need to create a unique workbook for every
unique name, while creating the worksheets in column A assigned to that
workbook in column B.
For example, the data below says that I will have one workbook named Alan
Groby. Inside of that workbook there will be two worksheets; one named
Import/Export Compliance and the other Video Conferencing. I have verified
that all column A data is correct symbols and length for worksheet names.
Then I am looking now but I will need to copy a source worksheet data into
each worksheet in every workbook. Basically this will a template for each
worksheet; it just has some colors and stuff that is it. But my main goal is
to get workbook and worksheets created ASAP. Thank you

Column A Column B
Import/Export Compliance Alan Grobey
Video Conferencing Alan Grobey
Disaster Recovery Proposal Anne Elledge
Upholstery Move Anthony Glathar
Trade Show Booth Bill Staser
Dental Furniture Special Bill Stewart
Cuspidor Replacement Prgm Bruno Zadnik
Raw material callout on dwgs Bruno Zadnik

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default Auto Create workbooks and worksheets per columnar data

Gentlemen,
THank you for your help, you came through and saved me hours worth of work.
I sincerely hope Microsoft truly understands the value you folks provide in
demonstrating the usefulness of their software.

"Tom Ogilvy" wrote:

Try something like this:

Sub NewList()
Dim rng As Range, cell As Range
Dim startrow As Long, sh As Worksheet
Dim bk as Workbook, startrow as Long
startrow = 2

With Worksheets("Sheet1")
Set rng = .Range(.Cells(startrow, 2), _
.Cells(startrow, 2).End(xlDown))
End With
For Each cell In rng
if cell.value < cell.offset(-1,0) then
if not bk is Nothing then _
bk.Close Savechange:=True
set bk = workbooks.Add(Template:=xlWBATWorksheet)
bk.worksheets(1).Name = cell.offset(0,-1).Value

' Change path in the next line

bk.SaveAs "c:\Myfolder\" & cell.Value & ".xls"
else
bk.Add After:=bk.Worksheets(bk.Worksheets.count)
activesheet.Name = cell.offset(0,-1)
end if
Next
if not bk is nothing then _
bk.Close Savechanges:=True
End Sub

--
Regards,
Tom Ogilvy


"Rookie_User" wrote:

I have a list of data below. I need to create a unique workbook for every
unique name, while creating the worksheets in column A assigned to that
workbook in column B.
For example, the data below says that I will have one workbook named Alan
Groby. Inside of that workbook there will be two worksheets; one named
Import/Export Compliance and the other Video Conferencing. I have verified
that all column A data is correct symbols and length for worksheet names.
Then I am looking now but I will need to copy a source worksheet data into
each worksheet in every workbook. Basically this will a template for each
worksheet; it just has some colors and stuff that is it. But my main goal is
to get workbook and worksheets created ASAP. Thank you

Column A Column B
Import/Export Compliance Alan Grobey
Video Conferencing Alan Grobey
Disaster Recovery Proposal Anne Elledge
Upholstery Move Anthony Glathar
Trade Show Booth Bill Staser
Dental Furniture Special Bill Stewart
Cuspidor Replacement Prgm Bruno Zadnik
Raw material callout on dwgs Bruno Zadnik

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
How to create multi columnar chart with 2 Y axis AND ALONG WITH TR viral_pandya_virurids[_2_] Charts and Charting in Excel 1 February 20th 08 08:33 AM
Copy/ move selected data from workbooks to seperate worksheets or workbooks Positive Excel Worksheet Functions 1 August 30th 07 04:54 PM
Auto Running Numbers in worksheets or workbooks Samantha Excel Worksheet Functions 0 November 16th 06 03:38 AM
Create workbooks from worksheets Ian in Ankara Excel Discussion (Misc queries) 3 February 28th 06 03:33 PM
Auto Create WorkBooks from Master File JavyD Excel Programming 1 September 4th 04 01:17 PM


All times are GMT +1. The time now is 10:29 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"