[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.1

Documenting VBA Code

Asked by cjinsocal581 in Microsoft Excel Spreadsheet Software

Thanks to GirardAndrew for the following code. What I need to know is how it references to each item in the spreadsheet. I am learning VBA code and am trying to get a handle on how it is different from VBScript. How references to rows, columns, cells, etc.

So if someone could help by commenting lines on each line of code to explain how they interact with the spreadsheet, I would be most appreciative.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
Public Category As String
Public CustRef As String
Public FirstName As String
Public LastName As String
Public Exec As String
Public UniqueID As String
Public xCategory As String
Public xCustRef As String
Public xFirstName As String
Public xLastName As String
Public xExec As String
Public xUniqueID As String
 
Public Function ConvertColumn(ColumnNumber As Integer)
    ConvertColumn = WorksheetFunction.Substitute(Cells(1, ColumnNumber).AddressLocal(RowAbsolute = True, ColumnAbslute = True), 1, "")
End Function
 
Private Sub InsertEntry(Category As String, CustRef As String, FirstName As String, LastName As String, Exec As String, RowN As Integer, UniqueID As String)
    If WorksheetFunction.CountIf(Sheets(Category).Range("X:X"), UniqueID) > 0 Then Exit Sub
    Sheets(Category).Range("A" & RowN).EntireRow.Insert
    Sheets(Category).Range("A" & RowN) = CustRef
    Sheets(Category).Range("E" & RowN) = FirstName
    Sheets(Category).Range("F" & RowN) = LastName
    Sheets(Category).Range("X" & RowN) = UniqueID
End Sub
 
Private Sub SendData()
    xCategory = ConvertColumn(WorksheetFunction.Match("Category", Range("1:1"), 0))
    xCustRef = ConvertColumn(WorksheetFunction.Match("Customer Reference Value", Range("1:1"), 0))
    xFirstName = ConvertColumn(WorksheetFunction.Match("First Name", Range("1:1"), 0))
    xLastName = ConvertColumn(WorksheetFunction.Match("Last Name", Range("1:1"), 0))
    xExec = ConvertColumn(WorksheetFunction.Match("Sr. Exec.", Range("1:1"), 0))
    xUniqueID = ConvertColumn(WorksheetFunction.Match("Unique ID", Range("1:1"), 0))
    For i = 2 To WorksheetFunction.CountA(Range("B:B"))
        Category = Range(xCategory & i)
        CustRef = Range(xCustRef & i)
        FirstName = Range(xFirstName & i)
        LastName = Range(xLastName & i)
        Exec = Range(xExec & i)
        UniqueID = Range(xUniqueID & i)
        On Error Resume Next
        Select Case Category
            Case "WC"
            Case "Corp"
                InsertEntry Category, CustRef, FirstName, LastName, Exec, WorksheetFunction.Match(Exec, Sheets(Category).Range("I:I"), 0), UniqueID
            Case Else
                InsertEntry Category, CustRef, FirstName, LastName, Exec, 7, UniqueID
        End Select
    Next i
End Sub
 
 
Private Sub CommandButton1_Click()
SendData
End Sub
Attachments:
 
Comment on code
 
 
Related Solutions
 
Loading Advertisement...
 
[+][-]08/21/09 10:28 AM, ID: 25153920Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/21/09 10:32 AM, ID: 25153954Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/21/09 10:51 AM, ID: 25154142Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: Microsoft Excel Spreadsheet Software
Sign Up Now!
Solution Provided By: BarryTice
Participating Experts: 3
Solution Grade: A
 
[+][-]08/28/09 01:41 PM, ID: 25211397Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091021-EE-VQP-81 - Hierarchy / EE_QW_3_20080625