rogerbowering
New Member
- Joined
- Apr 29, 2013
- Messages
- 14
Hi
I have a dataset from a relational database that I ma using Excel VBA to format from one worksheet to another
I take the raw export data and depending on whether it's header or child record data I format it a certain way in the worksheet
I've two worksheets 'Export' where the Database dataset is exported to and 'Report' where I'm copying formatted data into using VBA
So....I loop through and reformat the cells
As I go through the 'child' data the cells always copy over EXCEPT the last record!!! And I can't figure why. My VBA is crude but every 'child' record gets copied from one sheet to the other using:
When I'm debugging I can watch the last child record being processed and the data is going into the variables ok but it isn't going in to the cells in the 'Report' sheet. It's always the last child record, so I have a beautifully formatted Report missing one child record in every record set
Grrrrrrrrrrrrrrrrrrr
I have a dataset from a relational database that I ma using Excel VBA to format from one worksheet to another
I take the raw export data and depending on whether it's header or child record data I format it a certain way in the worksheet
I've two worksheets 'Export' where the Database dataset is exported to and 'Report' where I'm copying formatted data into using VBA
So....I loop through and reformat the cells
As I go through the 'child' data the cells always copy over EXCEPT the last record!!! And I can't figure why. My VBA is crude but every 'child' record gets copied from one sheet to the other using:
Code:
Sheets("Export").Select
HistDate = Cells(Row, 8)
Updater = Cells(Row, 9)
notes = Cells(Row, 10)
HistStatus = Cells(Row, 11)
ActionWith = Cells(Row, 12)
CompletionDate = Cells(Row, 13)
'RptRow = RptRow + 1
'Sheets("Headings").Select
'Range("A2:H2").Select
'Selection.Copy
'Sheets("Report").Select
'RangeCalc = "A" & RTrim(RptRow)
'Cells(RptRow, 1).Select
'ActiveSheet.Paste
Sheets("Report").Select
RptRow = RptRow + 1
Cells(RptRow, 2) = HistDate
Cells(RptRow, 3) = Updater
Cells(RptRow, 4) = notes
Cells(RptRow, 5) = HistStatus
Cells(RptRow, 6) = ActionWith
Cells(RptRow, 7) = CompletionDate
End If
Row = Row + 1
Grrrrrrrrrrrrrrrrrrr
Last edited by a moderator: