Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

subtotals fill blanks

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Subtotals fill blanks

Subtotals fill blanks

ResolvedVersion 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 courses

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
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.

Excel tip:

Quickly hide and unhide rows and columns

Use the keyboard shortcut Ctrl+9 to hide selected rows and Ctrl+0 to hide selected columns. The good thing about this shortcut is that you do not need to select entire rows or columns. For example, select B3:D3 then press Ctrl+0 to hide columns B to D.

Ctrl+Shift+9 unhides rows and Ctrl+Shift+0 unhides columns.

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.1 secs.