Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
VanessaNY
 
Posts: n/a
Default Import txt file with multiple rows for each record

I have a royalty report from SAP that I need to bring into Excel. It
includes check number, payment date, amount, and check recipient.

The problem is the "check recipient" information comes in on either 1,2,3,
or 4 lines in the report. But the rest of the record information is all on
line 1. This is random and will not be the EXACT same structure each month.

Ex.
2539893 3/14/2002 55.09 Jane Doe
Anytown USA
2539894 3/14/2002 79.99 Bob Evans
2539895 3/14/2002 5.00 John Smith
111 Main Street
Anytown USA

I need the end result to look like
2539893 3/14/2002 55.09 Jane Doe Anytown USA
2539894 3/14/2002 79.99 Bob Evans
2539895 3/14/2002 5.00 John Smith 111 Main Street Anytown USA

I have very little VBA or Macro experience, but wiling to learn. Also,
could Access handle this better?

  #2   Report Post  
Mike
 
Posts: n/a
Default

I can fix it in 10 minutes. Can you email it to me?

"VanessaNY" wrote:

I have a royalty report from SAP that I need to bring into Excel. It
includes check number, payment date, amount, and check recipient.

The problem is the "check recipient" information comes in on either 1,2,3,
or 4 lines in the report. But the rest of the record information is all on
line 1. This is random and will not be the EXACT same structure each month.

Ex.
2539893 3/14/2002 55.09 Jane Doe
Anytown USA
2539894 3/14/2002 79.99 Bob Evans
2539895 3/14/2002 5.00 John Smith
111 Main Street
Anytown USA

I need the end result to look like
2539893 3/14/2002 55.09 Jane Doe Anytown USA
2539894 3/14/2002 79.99 Bob Evans
2539895 3/14/2002 5.00 John Smith 111 Main Street Anytown USA

I have very little VBA or Macro experience, but wiling to learn. Also,
could Access handle this better?

  #3   Report Post  
VanessaNY
 
Posts: n/a
Default

Sure, what is your email?
I also need to learn ~how~ to do this, I have to do this monthly. Will you
be able to explain how to do it for me? :-)

"Mike" wrote:

I can fix it in 10 minutes. Can you email it to me?

"VanessaNY" wrote:

I have a royalty report from SAP that I need to bring into Excel. It
includes check number, payment date, amount, and check recipient.

The problem is the "check recipient" information comes in on either 1,2,3,
or 4 lines in the report. But the rest of the record information is all on
line 1. This is random and will not be the EXACT same structure each month.

Ex.
2539893 3/14/2002 55.09 Jane Doe
Anytown USA
2539894 3/14/2002 79.99 Bob Evans
2539895 3/14/2002 5.00 John Smith
111 Main Street
Anytown USA

I need the end result to look like
2539893 3/14/2002 55.09 Jane Doe Anytown USA
2539894 3/14/2002 79.99 Bob Evans
2539895 3/14/2002 5.00 John Smith 111 Main Street Anytown USA

I have very little VBA or Macro experience, but wiling to learn. Also,
could Access handle this better?

  #4   Report Post  
VanessaNY
 
Posts: n/a
Default

Mike I sent it about 75 minutes ago.. did you get it? Any help is appreciated.

"VanessaNY" wrote:

Sure, what is your email?
I also need to learn ~how~ to do this, I have to do this monthly. Will you
be able to explain how to do it for me? :-)

"Mike" wrote:

I can fix it in 10 minutes. Can you email it to me?

"VanessaNY" wrote:

I have a royalty report from SAP that I need to bring into Excel. It
includes check number, payment date, amount, and check recipient.

The problem is the "check recipient" information comes in on either 1,2,3,
or 4 lines in the report. But the rest of the record information is all on
line 1. This is random and will not be the EXACT same structure each month.

Ex.
2539893 3/14/2002 55.09 Jane Doe
Anytown USA
2539894 3/14/2002 79.99 Bob Evans
2539895 3/14/2002 5.00 John Smith
111 Main Street
Anytown USA

I need the end result to look like
2539893 3/14/2002 55.09 Jane Doe Anytown USA
2539894 3/14/2002 79.99 Bob Evans
2539895 3/14/2002 5.00 John Smith 111 Main Street Anytown USA

I have very little VBA or Macro experience, but wiling to learn. Also,
could Access handle this better?

  #5   Report Post  
Dave Peterson
 
Posts: n/a
Default

Try this against a copy of your worksheet--it destroys the original data as it
processes the data. (Or just close without saving if it's wrong.)

Option Explicit
Sub testme()

Dim wks As Worksheet
Dim FirstRow As Long
Dim LastRow As Long
Dim TopRow As Long
Dim iRow As Long
Dim dummyRng As Range
Dim rngToCopy As Range

Set wks = Worksheets("Sheet1")
With wks
FirstRow = 1
Set dummyRng = .UsedRange 'try to reset last used cell
LastRow = .Cells.SpecialCells(xlCellTypeLastCell).Row

TopRow = FirstRow
For iRow = FirstRow To LastRow Step 1
If IsEmpty(.Cells(iRow, "A")) = False Then
TopRow = iRow
Else
If Application.CountA(.Rows(iRow)) 0 Then
'found some stuff to move
Set rngToCopy = .Range(.Cells(iRow, "A").End(xlToRight), _
.Cells(iRow, .Columns.Count).End(xlToLeft))
rngToCopy.Copy _
Destination:=.Cells(TopRow, .Columns.Count) _
.End(xlToLeft).Offset(0, 1)
End If
End If
Next iRow

On Error Resume Next
.Range("a1").EntireColumn.Cells.SpecialCells(xlCel lTypeBlanks) _
.EntireRow.Delete
On Error GoTo 0
End With
End Sub

It looks at column A. If that cell is filled in, it knows to use that to
receive the other row's info.

If column A is empty, then it finds the first column with data and the last
column with data and copies it after the rightmost cell of that row with
something in column A.

When it's done, it deletes all the rows that have column A empty.

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm


VanessaNY wrote:

I have a royalty report from SAP that I need to bring into Excel. It
includes check number, payment date, amount, and check recipient.

The problem is the "check recipient" information comes in on either 1,2,3,
or 4 lines in the report. But the rest of the record information is all on
line 1. This is random and will not be the EXACT same structure each month.

Ex.
2539893 3/14/2002 55.09 Jane Doe
Anytown USA
2539894 3/14/2002 79.99 Bob Evans
2539895 3/14/2002 5.00 John Smith
111 Main Street
Anytown USA

I need the end result to look like
2539893 3/14/2002 55.09 Jane Doe Anytown USA
2539894 3/14/2002 79.99 Bob Evans
2539895 3/14/2002 5.00 John Smith 111 Main Street Anytown USA

I have very little VBA or Macro experience, but wiling to learn. Also,
could Access handle this better?


--

Dave Peterson
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
vlookup multiple text rows Tanya Excel Discussion (Misc queries) 4 August 15th 05 04:50 PM
looking for a calendar template that I can import multiple dates bkrizman Excel Discussion (Misc queries) 0 June 1st 05 11:16 PM
generate multiple rows based on cell value Theresa Excel Worksheet Functions 0 May 25th 05 11:18 PM
Read Text File into Excel Using VBA Willie T Excel Discussion (Misc queries) 13 January 8th 05 12:37 AM
Multiple rows of data on a single axis (charting) ramseysgirl Charts and Charting in Excel 8 December 29th 04 06:00 PM


All times are GMT +1. The time now is 04:34 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"