excel microsoft training - vba excel
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 Training and help » excel microsoft training - VBA for excel

excel microsoft training - VBA for excel

resolvedResolved · Low Priority · Version Standard

replyReply Fri 14 Dec 2007, 16:12Delegate Sven said...

Sven has attended:
Excel VBA Intro Intermediate course

VBA for excel

How can I count empty cells in a row or column? How can I use VBA to export data from excel (a table)to a word application?

For upcoming training course dates see: Pricing & availability

replyReply Fri 4 Jan 2008, 09:44Trainer Stephen said...

RE: VBA for excel

Hi Sven

Thank you for your question

For the first part, here is some code that should meet your needs. Note that it specifies the worksheet (data sheet) and range (data) of the cells to be checked

Public Sub GapCounter()


Dim aRange As Range
Dim i As Integer
Dim j As Integer
Dim Blanks As Integer

Worksheets("data sheet").Activate

Set aRange = Range("data")
Blanks = 0

For i = 1 To aRange.Columns.Count 'cycles through the columns
For j = 1 To aRange.Rows.Count 'within each column cycles through the rows
If IsEmpty(aRange.Cells(j, i)) Then
Blanks = Blanks + 1 'if the cell is empty, increases number of blanks by 1
End If
Next j
Next i

MsgBox ("There are " & Blanks & " Blank Cells in the range")


End Sub


As regards the second part of the question. Do you wish to amend the data once it is transfered into word? Or dio you simply wish a picture of the table to appear in the document?

Regards

Stephen

 

Excel tip:

Naming and Using Constants

Constants make calculations easier so worksheets are more easily understood. Constant values also need to be given relevant and memorably names. It is also easier to change the value of a constant.

For example:
Instead of entering 17.5% in each cell when you generate a VAT amount you could name a Constant "VAT" and assigning a "0.175" value to it. To do this:

From the 'Insert' menu select 'Name', then select 'Define'.

Enter the constant

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