vba office
Microsoft Office Training verified by visa - mastercard securecode about microsoft training company london ukadd this page to your favourites/bookmarksAdd to favourites
view a printable version of this pagePrintable version
email this page to somebodyEmail this page
Customer: Sign in
Delegate: Sign in
Trainer: Log in

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and Help » VBA in office 2007

VBA in office 2007

The UK's most regular instructor-led training courses.
Training information: excel-training-courses · Microsoft excel training · VBA courses London

resolvedResolved · Low Priority · Version Standard

VBA in office 2007

Nathan has attended:
Excel VBA course

by - delegate Nathan [1 post] (2008 Feb 21 Thu, 10:16) replyReply

Hi Carlos

I'm thinking of upgrading to office 2007 from 2003, are you aware of any differences with the code/layout in the new office package?

Also, do you remember our conversation about counting coloured cells?

Thanks
Nathan

Excel Advanced 1 day course
Version Date Location Places
available
Book Next place rate:
Card Invoice
2007 2008 Jul 9 Wed Bloomsbury 0 FULL    
2003/XP 2008 Jul 9 Wed Bayswater 2 book now £195 £205
2003/XP 2008 Jul 16 Wed Tooting 0 FULL    
2003/XP 2008 Jul 16 Wed Bloomsbury 1 book now £235 £240
2003/XP 2008 Jul 18 Fri Southwark 4 book now £224 £235
2003/XP 2008 Jul 23 Wed Southwark 0 FULL    
Full Schedule: See all 143 Excel Advanced course dates.
Bookings currently available until 24th November 2009.

Count Cells according to Colours & VBA in Office 2007

by - trainer Carlos gold contributer[360 posts] (2008 Feb 29 Fri, 16:02) replyReply

Nathan

I have run the code I usually use in the course in 2007 and there have been no problems.

The Visual Basic Editor (VBE) hasn't had any major changes

As for the code to count coloued cells do the following:

1. Open the VBE and create a Module in either the document where the code is to run or in the Personal Macro Workbook.

2. Copy the following code into the module:

Public Function CountByColour(MyRange As Range, MyColorIndex As Integer, _
Optional OfText As Boolean = False) As Long

' This function return the number of cells in MyRange with 
' a background color, or if OfText is True a font color, 
' equal to MyColorIndex.
'
Dim RangeVar As Range

Application.Volatile True

For Each RangeVar In MyRange.Cells

If OfText = True Then

CountByColour = CountByColour - (RangeVar.Font.ColorIndex = MyColorIndex)

Else

CountByColour = CountByColour - (RangeVar.Interior.ColorIndex = MyColorIndex)

End If

Next RangeVar

End Function


3. Now in the spreadsheet select the cell where the count value is to go

4. In the function dialog box select User Defined and then select the CountByColour function as Below:

In the example 5 is the Colour Index for Blue

To count cells where the Background is Blue

=CountByColour(A1:A13,5)

To Count cells where the Text is Blue

=CountByColour(A1:A13,5, TRUE)

Hope this helps

Carlos


Related articles

· How to Create Better Excel Spreadsheets: Part One
· Microsoft Excel Training Course
· Microsoft Excel Features and Functions for Accountants
· How to Create Better Excel Spreadsheets: Part Four
· 5 Microsoft Excel Charts for Creating Stunning Business Documents

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

Excel tip:

Shortcut keys to move between sheets

Instead of clicking on a sheet tab to view a sheet, use the following keyboard shortcuts to move between sheets in the same file:

Ctrl + Page Down - Switch to the next worksheet (to the right)

Ctrl + Page Up - Switch to the previous worksheet (to the left)

View all Excel hints and tips

Institute of IT Training - Accredited Training Provider Institute of IT Training - Accredited Training Provider Prodigy Platinum Learning Partner Microsoft Office Specialist Authorised Testing Centre

Microsoft Registered Partner
microsoft office
ms office project server

Association of Computer Trainers Valid HTML 4.01 Transitional
Valid CSS Markup

secure online payments - visa - mastercard

Mini sitemap. These are the main areas of our web site. Full sitemap.

Training by application Main information pages See also

Access courses
DreamWeaver courses
Excel courses
MS Project courses
Outlook courses
PowerPoint courses
VBA courses
Word courses
(more...)

Public scheduled courses
On-site training
Closed company courses

Microsoft Office training
Pricing and availability
Training schedule
Training venues

Access training
Dreamweaver training
Excel training
MS Project training
PowerPoint training

London Computer Training
Computer Training London

Microsoft Access training
Microsoft Excel training
Microsoft Project training
Microsoft Outlook training
Microsoft Powerpoint training
Microsoft Word training

Time Management Course London

Interested in Access training? Please see the following pages:
microsoft access courses · microsoft training access course
microsoft+access+training · access courses in london

Training Information
AddThis Social Bookmark Button What's this?
Add to Del.icio.us Add to Facebook Add to Digg Add to Reddit Add to Google Add to Yahoo Add to Diigo Add to Mr. Wong Add to Linkarena Add to Power Oldie Add to Folkd Add to Jumptags Add to Upchuckr Add to Simpy Add to StumbleUpon Add to Slashdot Add to Netscape Add to Furl Add to Spurl Add to Blinklist Add to Blogmarks Add to Technorati Add to Newsvine Add to Blinkbits Add to Ma.Gnolia Add to Smarking Add to Netvouz