Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi, I posted here earlier, but I think my post was too complicated. Here is
what I am really needing now. A file is downloaded off an AS/400 into an Excel worksheet (I am new to Excel, so please excuse my bad terminology). Sometimes there is only one record (which means one row), and sometimes there are several records (several rows). Essentially, I need a macro that can select the row, copy it, open a template I created and paste it into the template (as an xls). It will then save that file after the data located in a specific field name. The file is closed then it moves back to the file with the rest of the records. I want my macro to continue to move down the worksheet until all rows have been copied and pasted into new worksheets. 'This selected the specific data that was later used as a file name' Selection.Find.Execute Replace:=wdReplaceAll Selection.HomeKey Unit:=wdStory, Extend:=wdExtend Selection.MoveRight Unit:=wdCharacter, Count:=18, Extend:=wdExtend 'This code declared the selected data above as fname. It then saved the file with that data and moved onto the next record in the file.' fname = Selection Dim i As Integer, Source As Document, Target As Document Set Source = ActiveDocument For i = 1 To Source.Paragraphs.Count Set Target = Documents.Add Target.Range = Source.Paragraphs(i).Range Target.SaveAs Filename: = fname & ".doc" Target.Close Set Target = Nothing Next i Set Source = Nothing Thanks very much for any assistance you can provide. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Select dynamic data in 2 columns, and repeat macro to next sheet | Excel Discussion (Misc queries) | |||
Repeat copy for indifinate number of worksheets | Excel Discussion (Misc queries) | |||
copy a worksheet to new one with repeat rows 5 times | Excel Discussion (Misc queries) | |||
Repeat Cell Formula w/out copy/paste? | Excel Discussion (Misc queries) | |||
Simple (?) Macro Assistance- Select, Insert, Paste, Rinse, Repeat | Excel Programming |