Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 618
Default Question for complicated merge

Hi Jason

here's some code that takes each row in turn, starting at row 2 and puts it
into a new workbook and then saves the workbook using the name in cell G1.

Sub SplitWorkbook()

Do Until Range("A2").Value = ""
Rows("2:2").Select
Selection.Cut
Workbooks.Add
ActiveSheet.Paste
Range("A1").Select
ActiveWorkbook.SaveAs Filename:=Range("G1"), FileFormat:=xlNormal,
Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
ActiveWindow.Close
Selection.Delete Shift:=xlUp
Loop
End Sub

Please post back if you require further assistance.

Regards
JulieD

"Jason L" wrote in message
...
Hey, I'm very new to Excel and especially to Excel programming. I'm
currently working on a template that will allow a user to import data from

a
txt file into an excel template. This text file has multiple records in

it,
and each one has to be stored in a seperate excel file under a specific

field
entry (field G3). I've been doing this in Word, but Word's limitations

with
tables and comment problems has been limiting. Right now my idea is to

merge
the entire file into an Excel sheet and run a macro that will split each

row
into a separate excel worksheet with the specific name. These files then
need to be merged into another template that has the proper field headers.
This template also has user instructions entered into fields some of the
higher numbered fields. The user modifies these higher numbered fields

and
then will save this document and merge it into a Word document.

Here is the code I have for the splitting and saving of the excel
worksheets. I'd appreciate any insight or feedback here. This code is
essentially supposed to take each row in the first excel sheet, grab the
whole row, dump it into my template and save it according to the name

located
in G3. Thanks again for your help.

Sub BRPT()
Dim fname As String

Range("G3").Select

fname = Selection

Dim i As Integer, Source As Worksheet, Target As Worksheet
Set Source = ActiveWorkbook
For i = 1 To Source.Rows.Count
Set Target = Worksheet.Add
Target.Range = Source.Rows(i).Range
Target.SaveAs Filename:=fname & ".xls"
Target.Close
Set Target = Nothing
Next i
Set Source = Nothing


End Sub

-TIA, Jason



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 618
Default Question for complicated merge

Hi Jason

you're pasting before you're selecting & you're not deleting the row only
cutting the data

try
---
Sub SplitWorkbook()

Do Until Range("A1").Value = ""
'Since there are no field headers in the original file, I just had it
select the first row and cut.
Rows("1:1").Select
Selection.Cut
Workbooks.Add Template:="BRPT1.xlt"
'The name of the template is BRPT1.xlt.
Range("A2").Select
ActiveSheet.Paste

'Since there are headers in the template, the rows need to be dropped down
one row when they are pasted into the file.
ActiveWorkbook.SaveAs Filename:=Range("G2"), FileFormat:=xlNormal,
_
Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
ActiveWindow.Close
Selection.Delete Shift:=xlUp
Loop
End Sub

---

Cheers
JulieD


"Jason L" wrote in message
...
JulieD,

Thanks a lot. This is very close to what I want. As I was testing it, I
realized that I was wrong in some of my assumptions. First, the

downloaded
info can go into a regular, blank worksheet. It's from there that it

needs
to be split off and imported into separate workbooks with my created field
headers. Essentially, I need to do the same procedure, but I need to use

a
specific template that includes field headers. I changed the code some to
allow this, but I keep getting a 400 error.

Here is my code thus far:

Sub SplitWorkbook()

Do Until Range("A1").Value = ""
'Since there are no field headers in the original file, I just had it

select
the first row and cut.
Rows("1:1").Select
Selection.Cut
Workbooks.Add Template:="BRPT1.xlt"
'The name of the template is BRPT1.xlt.
ActiveSheet.Paste
Range("A2").Select
'Since there are headers in the template, the rows need to be dropped down
one row when they are pasted into the file.
ActiveWorkbook.SaveAs Filename:=Range("G2"), FileFormat:=xlNormal,

_
Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
ActiveWindow.Close

Loop
End Sub

TIA,
Jason

"JulieD" wrote:

Hi Jason

here's some code that takes each row in turn, starting at row 2 and puts

it
into a new workbook and then saves the workbook using the name in cell

G1.

Sub SplitWorkbook()

Do Until Range("A2").Value = ""
Rows("2:2").Select
Selection.Cut
Workbooks.Add
ActiveSheet.Paste
Range("A1").Select
ActiveWorkbook.SaveAs Filename:=Range("G1"),

FileFormat:=xlNormal,
Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
ActiveWindow.Close
Selection.Delete Shift:=xlUp
Loop
End Sub

Please post back if you require further assistance.

Regards
JulieD

"Jason L" wrote in message
...
Hey, I'm very new to Excel and especially to Excel programming. I'm
currently working on a template that will allow a user to import data

from
a
txt file into an excel template. This text file has multiple records

in
it,
and each one has to be stored in a seperate excel file under a

specific
field
entry (field G3). I've been doing this in Word, but Word's

limitations
with
tables and comment problems has been limiting. Right now my idea is

to
merge
the entire file into an Excel sheet and run a macro that will split

each
row
into a separate excel worksheet with the specific name. These files

then
need to be merged into another template that has the proper field

headers.
This template also has user instructions entered into fields some of

the
higher numbered fields. The user modifies these higher numbered

fields
and
then will save this document and merge it into a Word document.

Here is the code I have for the splitting and saving of the excel
worksheets. I'd appreciate any insight or feedback here. This code

is
essentially supposed to take each row in the first excel sheet, grab

the
whole row, dump it into my template and save it according to the name

located
in G3. Thanks again for your help.

Sub BRPT()
Dim fname As String

Range("G3").Select

fname = Selection

Dim i As Integer, Source As Worksheet, Target As Worksheet
Set Source = ActiveWorkbook
For i = 1 To Source.Rows.Count
Set Target = Worksheet.Add
Target.Range = Source.Rows(i).Range
Target.SaveAs Filename:=fname & ".xls"
Target.Close
Set Target = Nothing
Next i
Set Source = Nothing


End Sub

-TIA, Jason






  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 618
Default Question for complicated merge

Hi Jason

did you get it working?

Cheers
JulieD

"JulieD" wrote in message
...
Hi Jason

you're pasting before you're selecting & you're not deleting the row only
cutting the data

try
---
Sub SplitWorkbook()

Do Until Range("A1").Value = ""
'Since there are no field headers in the original file, I just had it
select the first row and cut.
Rows("1:1").Select
Selection.Cut
Workbooks.Add Template:="BRPT1.xlt"
'The name of the template is BRPT1.xlt.
Range("A2").Select
ActiveSheet.Paste

'Since there are headers in the template, the rows need to be dropped

down
one row when they are pasted into the file.
ActiveWorkbook.SaveAs Filename:=Range("G2"),

FileFormat:=xlNormal,
_
Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
ActiveWindow.Close
Selection.Delete Shift:=xlUp
Loop
End Sub

---

Cheers
JulieD


"Jason L" wrote in message
...
JulieD,

Thanks a lot. This is very close to what I want. As I was testing it,

I
realized that I was wrong in some of my assumptions. First, the

downloaded
info can go into a regular, blank worksheet. It's from there that it

needs
to be split off and imported into separate workbooks with my created

field
headers. Essentially, I need to do the same procedure, but I need to

use
a
specific template that includes field headers. I changed the code some

to
allow this, but I keep getting a 400 error.

Here is my code thus far:

Sub SplitWorkbook()

Do Until Range("A1").Value = ""
'Since there are no field headers in the original file, I just had it

select
the first row and cut.
Rows("1:1").Select
Selection.Cut
Workbooks.Add Template:="BRPT1.xlt"
'The name of the template is BRPT1.xlt.
ActiveSheet.Paste
Range("A2").Select
'Since there are headers in the template, the rows need to be dropped

down
one row when they are pasted into the file.
ActiveWorkbook.SaveAs Filename:=Range("G2"),

FileFormat:=xlNormal,
_
Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
ActiveWindow.Close

Loop
End Sub

TIA,
Jason

"JulieD" wrote:

Hi Jason

here's some code that takes each row in turn, starting at row 2 and

puts
it
into a new workbook and then saves the workbook using the name in cell

G1.

Sub SplitWorkbook()

Do Until Range("A2").Value = ""
Rows("2:2").Select
Selection.Cut
Workbooks.Add
ActiveSheet.Paste
Range("A1").Select
ActiveWorkbook.SaveAs Filename:=Range("G1"),

FileFormat:=xlNormal,
Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
ActiveWindow.Close
Selection.Delete Shift:=xlUp
Loop
End Sub

Please post back if you require further assistance.

Regards
JulieD

"Jason L" wrote in message
...
Hey, I'm very new to Excel and especially to Excel programming. I'm
currently working on a template that will allow a user to import

data
from
a
txt file into an excel template. This text file has multiple

records
in
it,
and each one has to be stored in a seperate excel file under a

specific
field
entry (field G3). I've been doing this in Word, but Word's

limitations
with
tables and comment problems has been limiting. Right now my idea is

to
merge
the entire file into an Excel sheet and run a macro that will split

each
row
into a separate excel worksheet with the specific name. These files

then
need to be merged into another template that has the proper field

headers.
This template also has user instructions entered into fields some of

the
higher numbered fields. The user modifies these higher numbered

fields
and
then will save this document and merge it into a Word document.

Here is the code I have for the splitting and saving of the excel
worksheets. I'd appreciate any insight or feedback here. This

code
is
essentially supposed to take each row in the first excel sheet, grab

the
whole row, dump it into my template and save it according to the

name
located
in G3. Thanks again for your help.

Sub BRPT()
Dim fname As String

Range("G3").Select

fname = Selection

Dim i As Integer, Source As Worksheet, Target As Worksheet
Set Source = ActiveWorkbook
For i = 1 To Source.Rows.Count
Set Target = Worksheet.Add
Target.Range = Source.Rows(i).Range
Target.SaveAs Filename:=fname & ".xls"
Target.Close
Set Target = Nothing
Next i
Set Source = Nothing


End Sub

-TIA, Jason








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
IF question complicated [email protected] Excel Discussion (Misc queries) 4 January 25th 09 02:23 PM
Complicated Mail Merge that is over my head. InvaderJim Excel Discussion (Misc queries) 1 January 24th 08 12:21 AM
Complicated mail merge [email protected] Excel Discussion (Misc queries) 1 November 25th 06 12:34 AM
Complicated question Jasdf Excel Discussion (Misc queries) 1 November 8th 06 01:08 PM
Complicated Question kyrospeare Excel Worksheet Functions 5 April 27th 06 02:45 AM


All times are GMT +1. The time now is 05:11 AM.

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"