PC Review


Reply
Thread Tools Rate Thread

Data to new Workbook

 
 
Midget
Guest
Posts: n/a
 
      4th May 2007
Here is the problem, I have a worksheet in which there are 3 columns.
Column A contains the names of new workbooks, Column B contains the
names of the new worksheets within the new workbook, and Column C
contains the data for each worksheet within the workbook. My data
looks something like the following...
A B C
1 Close F Street A3590 Removals
2 A3600 Road Exc.
3 Temp Tie In A3630 Removals
4 A3640 Road Exc.
5 Connect to D Street A3660 Removals.

Is what I am trying to do even possible? To re-explain this with the
example above...
I want this to create a new Workbook called Close F Street, that
workbook will have 2 worksheets called A3590 and A 3600, and The
column C data will be in Cell 18, so Sheet A3590 will have Removals in
Cell 18 and Sheet A3600 will have Road Exc. in Cell 18.

I hope this makes sense. I have tried to accomplish this on my own
but can't get anywhere.

Thanks for your response.

Ryan

 
Reply With Quote
 
 
 
 
=?Utf-8?B?SkxHV2hpeg==?=
Guest
Posts: n/a
 
      4th May 2007
Your explanation is a little confusing.
Is the worksheet you are illustrating as an example included in one of the
new workbooks or is it to be an index to the new workbooks, making it a
fourth workbook? The active workbook plus three new workbooks as illustrated?
The illustration indicates thay Column A in the new workbooks might be have
vertically merged cells, is that what you have done so that the worksheets
are easily identified to their workbooks, or is it just a manual index
listing?
When you refer to cell 18, which worksheets are you referring to and what
column would that cell be found in, A, B or C? or other?

If you can be a little more clear in your explanation, I am sure someone
will help you.

"Midget" wrote:

> Here is the problem, I have a worksheet in which there are 3 columns.
> Column A contains the names of new workbooks, Column B contains the
> names of the new worksheets within the new workbook, and Column C
> contains the data for each worksheet within the workbook. My data
> looks something like the following...
> A B C
> 1 Close F Street A3590 Removals
> 2 A3600 Road Exc.
> 3 Temp Tie In A3630 Removals
> 4 A3640 Road Exc.
> 5 Connect to D Street A3660 Removals.
>
> Is what I am trying to do even possible? To re-explain this with the
> example above...
> I want this to create a new Workbook called Close F Street, that
> workbook will have 2 worksheets called A3590 and A 3600, and The
> column C data will be in Cell 18, so Sheet A3590 will have Removals in
> Cell 18 and Sheet A3600 will have Road Exc. in Cell 18.
>
> I hope this makes sense. I have tried to accomplish this on my own
> but can't get anywhere.
>
> Thanks for your response.
>
> Ryan
>
>

 
Reply With Quote
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      4th May 2007
Assumes your data starts in A1 of the Activesheet when you run the macro.

Make custom changes as indicated in the macro.

Sub CreateBooks()
Dim sh As Worksheet, bk As Workbook
Dim shNew As Long, rng As Range, rng1 As Range
Dim cell As Range, cell1 As Range
Dim rStart As Range, sName As String
Dim rw As Long, sPath As String
Dim i As Long

' Change the next line to reflect your path

sPath = "C:\Data2\Test\"


Set sh = ActiveSheet
shNew = Application.SheetsInNewWorkbook
Set rng = sh.Range("A1", sh.Cells(Rows.Count, 2).End(xlUp).Offset(1, -1))
rw = rng.Rows(rng.Rows.Count).Row
Set rStart = rng(1).Offset(0, 1)
sName = rng(1).Value & ".xls"
For Each cell In rng
If Not IsEmpty(cell) Or cell.Row = rw Then
If cell.Row <> 1 Then
Set rng1 = sh.Range(rStart, cell.Offset(-1, 1))
Application.SheetsInNewWorkbook = rng1.Rows.Count
Workbooks.Add
Set bk = ActiveWorkbook
i = 0
For Each cell1 In rng1
i = i + 1
With bk.Worksheets(i)
'
' change "C18" to reflect whatever you meant by "Cell 18"
'
.Range("C18").Value = cell1.Offset(0, 1)
.Name = cell1.Value
End With
Next
bk.SaveAs sPath & sName
bk.Close SaveChanges:=False
sName = cell.Value & ".xls"
Set rStart = cell.Offset(0, 1)
End If
End If
Next
End Sub

--
Regards,
Tom Ogilvy


"Midget" wrote:

> Here is the problem, I have a worksheet in which there are 3 columns.
> Column A contains the names of new workbooks, Column B contains the
> names of the new worksheets within the new workbook, and Column C
> contains the data for each worksheet within the workbook. My data
> looks something like the following...
> A B C
> 1 Close F Street A3590 Removals
> 2 A3600 Road Exc.
> 3 Temp Tie In A3630 Removals
> 4 A3640 Road Exc.
> 5 Connect to D Street A3660 Removals.
>
> Is what I am trying to do even possible? To re-explain this with the
> example above...
> I want this to create a new Workbook called Close F Street, that
> workbook will have 2 worksheets called A3590 and A 3600, and The
> column C data will be in Cell 18, so Sheet A3590 will have Removals in
> Cell 18 and Sheet A3600 will have Road Exc. in Cell 18.
>
> I hope this makes sense. I have tried to accomplish this on my own
> but can't get anywhere.
>
> Thanks for your response.
>
> Ryan
>
>

 
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
Macro to copy specific data from master workbook to another workbook Mark767 Microsoft Excel Programming 13 1st Sep 2009 08:57 PM
Copy data from Workbook Alpha & reorganize it in Workbook Bravo u473 Microsoft Excel Programming 1 31st Oct 2007 02:37 AM
1.Open workbook. 2 copy data. 3 replace data. 4 save workbook. Cristobalitotom Microsoft Excel Programming 0 6th Jul 2006 12:24 AM
loop through a column on a workbook copying data on each row to another workbook, then copy data back to the original workbook burl_rfc Microsoft Excel Programming 1 1st Apr 2006 08:48 PM
Open a password protected excel workbook from second workbook to fetch data using dynamic connection kaustav choudhury Microsoft Excel Programming 2 3rd Apr 2004 06:18 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:15 AM.