LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #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



 
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 10:10 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"