Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Fatboymedic
 
Posts: n/a
Default need help reformatting spreadsheet

I have a spreadsheet that i exported from an old database program, in CSV
format. I have it saved as a xls now, and my data is laid out like:

lastname firstname dob date01 date 02 date 03 ticket01 ticket02
ticket03 (etc)
lastname firstname dob date01 date 02 date 03 ticket01 ticket02
ticket03

I NEED (for importing into an access database)

lastname firstname dob date01 ticket01
lastname firstname dob date02 ticket02
lastname firstname dob date03 ticket03

I have 2365 individual names... some with one date/ticket entry, some with
10....

HELP!?


  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default need help reformatting spreadsheet

And all the dates come before all the tickets?

Then this seemed to work ok:

Option Explicit
Sub testme()

Dim curWks As Worksheet
Dim newWks As Worksheet
Dim oRow As Long
Dim iRow As Long
Dim FirstRow As Long
Dim LastRow As Long
Dim LastCol As Long
Dim FirstCol As Long
Dim iCol As Long
Dim QtyOfTickets As Double

Set curWks = Worksheets("sheet1")
Set newWks = Worksheets.Add

With curWks
FirstRow = 1
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
FirstCol = 4 'ignore the "headers"

oRow = 1
For iRow = FirstRow To LastRow
LastCol = .Cells(iRow, .Columns.Count).End(xlToLeft).Column
QtyOfTickets = (LastCol - FirstCol + 1) / 2
If Int(QtyOfTickets) < QtyOfTickets Then
MsgBox "Something bad happened on row #: " & iRow & vbLf _
& "Not completed!"
Exit Sub
End If
newWks.Cells(oRow, "A").Resize(QtyOfTickets, 3).Value _
= .Cells(iRow, "A").Resize(1, 3).Value
For iCol = 1 To QtyOfTickets
newWks.Cells(oRow, "D").Value _
= .Cells(iRow, FirstCol + iCol - 1).Value
newWks.Cells(oRow, "E").Value _
= .Cells(iRow, FirstCol + iCol - 1).Value
oRow = oRow + 1
Next iCol
Next iRow
End With
End Sub



Fatboymedic wrote:

I have a spreadsheet that i exported from an old database program, in CSV
format. I have it saved as a xls now, and my data is laid out like:

lastname firstname dob date01 date 02 date 03 ticket01 ticket02
ticket03 (etc)
lastname firstname dob date01 date 02 date 03 ticket01 ticket02
ticket03

I NEED (for importing into an access database)

lastname firstname dob date01 ticket01
lastname firstname dob date02 ticket02
lastname firstname dob date03 ticket03

I have 2365 individual names... some with one date/ticket entry, some with
10....

HELP!?



--

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
Formula for Returning values in another spreadsheet lrbest4x4xfar Excel Worksheet Functions 1 October 14th 05 02:52 PM
Hyperlinking to Excel 2000 with a linked spreadsheet LDPitsy1970 Excel Discussion (Misc queries) 0 October 12th 05 02:31 PM
Spreadsheet merging problems Sam B Excel Worksheet Functions 0 September 19th 05 08:05 PM
Spreadsheet Dilemma msbates2004 Excel Discussion (Misc queries) 1 May 27th 05 02:55 AM
Applying Existing Password to New Spreadsheet Vic Excel Discussion (Misc queries) 1 January 27th 05 12:37 AM


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