So infuriating!!! Placing values into cells works except for last row

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:
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
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
 
Last edited by a moderator:
I don't see how with your code. Bit of a long shot, but you don't have any white fonts in use do you?

And...for some reason those rows aren't empty, they have white font

Holy cow! An amazing bullseye shot in a coalbin in the dead of night!
 
Upvote 0

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Yes the main Header Row is blue background, white font and bold (Sub-header rows grey background, black font). I've noticed some of my output is bold where I wouldn't expect it to be. Maybe the simplest things is to avoid any formatting during the code (everything plain, black on white font). I* could then macro the formatting afterwards
 
Upvote 0

Forum statistics

Threads
1,223,264
Messages
6,171,081
Members
452,377
Latest member
bradfordsam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top