Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Select a row, copy and repeat on the next row

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
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
Select dynamic data in 2 columns, and repeat macro to next sheet Tasha Excel Discussion (Misc queries) 2 September 17th 09 07:00 PM
Repeat copy for indifinate number of worksheets ARbitOUR[_5_] Excel Discussion (Misc queries) 3 May 5th 09 03:00 AM
copy a worksheet to new one with repeat rows 5 times mfn Excel Discussion (Misc queries) 0 February 13th 08 11:33 AM
Repeat Cell Formula w/out copy/paste? DTTODGG Excel Discussion (Misc queries) 1 March 13th 06 05:11 PM
Simple (?) Macro Assistance- Select, Insert, Paste, Rinse, Repeat Pete_CSC Excel Programming 4 June 15th 04 05:09 PM


All times are GMT +1. The time now is 09:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"