98.7% Of all customers recommend us, we're so confident about our results we publish all reviews and stats
View Live Stats View ReviewsForum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Subtotals fill blanks
Subtotals fill blanks
Resolved · Low Priority · Version 2003
Justine has attended:
Excel Advanced course
Excel VBA Intro Intermediate course
Excel VBA Advanced course
Subtotals fill blanks
how would you code in the step to select blank cells in paticular columns and fill them with the information from the cell above.
This is to achieve a complete table when viewing a summary so the visible cells can be copied into a new report of standard format.
RE: subtotals fill blanks
Hi Justine
Thankyou for your qusetion
The following code will go through each cell in the current region and if the cell is empty will set its value equal to the cells above it
Sub FillBlanks()
Dim intRowcount As Integer
Dim intColumnCount As Integer
For intRowcount = 2 To Range("A1").CurrentRegion.Rows.Count
For intColumnCount = 1 To Range("A1").CurrentRegion.Columns.Count
If Cells(intRowcount, intColumnCount) = "" Then
Cells(intRowcount, intColumnCount) = Cells(intRowcount - 1, intColumnCount)
End If
Next intColumnCount
Next intRowcount
End Sub
Regards
Stephen
Mon 12 Jan 2009: Automatically marked as resolved.
Training information:
Welcome. Please choose your application (eg. Excel) and then post your question. Our Microsoft Qualified trainers will then respond within 24 hours (working days). Frequently Asked Questions
Any suggestions, questions or comments? Please post in the Improve the forum thread. |
Excel tip:Move to edge of data blockWhen data is held in a block, however large, use the Ctrl key with your cursors to move quickly to the far edge of the block. Works with all 4 direction keys. |