Computer problems,Computer help
*AX SOFT>>>Programming & Design

Trying to understand a piece of code in VBA [excel]?


Hi everyone,

A friend of mine sent me this code and I need to be able to describe it to my peers, I need a part by part description and an overview of what the entire piece does.

[code]
Sub Processor()
Dim ConstantCells As Range
Dim FormulaCells As Range
Dim cell As Range
' Ignore Errors
On Error Resume Next
' Process the constants
Set ConstantCells = Selection.SpecialCells(xlConstants)
For Each cell In ConstantCells
If cell.Value > 0 Then
cell.Interior.ColorIndex = 6
End If
Next cell
' Process the formulas
Set FormulaCells = Selection.SpecialCells(xlFormulas)
For Each cell In FormulaCells
If cell.Value > 0 Then
cell.Interior.ColorIndex = 7
End If
Next cell
End Sub
[/code]

Thanks in advance! I really appreciate any help that can be given.

Cheers

Sub Processor() ->Beginning of subroutine:Processor
Dim ConstantCells As Range ->Define ConstantCells as a range of cells
Dim FormulaCells As Range
->like above statement
Dim cell As Range
->like above statement
' Ignore Errors -> Statement starts wtih ' means comment
On Error Resume Next ->If exception/error happen,goto tag: Next
' Process the constants ->comment
Set ConstantCells = Selection.SpecialCells(xlConst...
->Set ConstantCells = the cells selected by you in the excel
For Each cell In ConstantCells-> All this statemet is to turn
the color the cells in the range to red while cell>0
If cell.Value > 0 Then
cell.Interior.ColorIndex = 6
End If
Next cell ' Process the formulas
Set FormulaCells = Selection.SpecialCells(xlFormu...
For Each cell In FormulaCells
->like above statements
If cell.Value > 0 Then
cell.Interior.ColorIndex = 7
End If
Next cell
End Sub ->tag to end the subroutine

Tags
  General - Computers & Internet   Software   Security   Programming & Design   Facebook   Flickr   Google   MSN   MySpace
Related information
  • How do I keep a running total score in c++?

    Set the value to 0 above the loop and add to the value test = 0; loop{ score = 15; test+=score; } cout << test

    ...
  • Use ASP .NET's membership system or roll your own?

    Well the pro's are pretty obvious. It offers you a ready component for use to save/retrieve users for your website, it integrates pretty well very easily with Login server controls thus saving...

  • Is there an equivalent for the GetChar() function from VB.Net in VB6?

    Have you tried Mid(String,Index,Length)? MyString = "HELLO!" Print Mid(MyString,2,1) Would print "E"

    ...
  • ASCII/ANSI Character codes?

    You need to look at unicode, ASCII only covers the 256 characters, Unicode however uses 4 Bytes (32 bits) to store the character information (as opposed to two) and so can store mush more. As fo...

  • Sending POST Using <a href=...> instead of the submit button?

    What about using JavaScript to submit hidden forms when the link is clicked? :) For instance.. <form action="post.php" id="frm" method="post" style="displa...

  • In JSP I want to print out my database entries with the newest first?

    Order them in the DB query. Instead of SELECT * FROM ARTICLE Use something like SELECT * FROM ARTICLE ORDER BY Date DESC If you don't have a Date column use what ever column deno...

  • In Java, how do you outline a Polyline?

    you could try drawing the line twice. first in black with width 2 pixels and then in green with width 1 pixel.

    ...
  • How much to charge for making an ecommerce website for a small business?

    concentrate on the design work, do a mock up or a layout first, and get their interest. Give them a full list of all the functions.... Don't focus/talk on price, focus on what you will be of...

  •  

    Categories--Copyright/IP Policy--Contact Webmaster