subtotals fill blanks
The UK's Number 1 for Microsoft Office Training Add this page to your favourites/bookmarksBookmark page
 
View printable version of pagePrintable version
Plus One Google
Customer: Sign in
Delegate: Sign in
Trainer: Log in

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

Subtotals fill blanks

resolvedResolved · Low Priority · Version 2003

replyReply Tue 16 Dec 2008, 15:52Delegate Justine said...

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

replyReply Mon 5 Jan 2009, 14:41Trainer Stephen said...

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.

 

Please browse our web site to find out more about
excel+vba+training and other Microsoft training courses.

Excel tip:

Using Excel's MODE function

Use Excel's MODE function to display the most common value present in a particular range of cells.

The Mode function looks like this:

=MODE(cell range)

As an example, if 35 is the most commonly recurring number in a particular cell range, then the function will display 35.

View all Excel hints and tips


Microsoft Certified Partner Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses Security Seal verified by visa, mastercard securecard