Forum 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.
For upcoming training course dates see: Pricing & availability
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.
|
