Advertisement

05.30.2008 at 08:17AM PDT, ID: 23444874
[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.7

VBA code problem

Asked by lee_jd in Microsoft Excel Spreadsheet Software

Tags: , ,

I am developing an error tracking report.  This report looks at series of files and checks for various logic errors and when it finds an error it reports this along with the location of the problem cell.

I've written code that works once but something is not right.  When I step through the code in the ReportError sub the code jumps ahead.   When the code loops I don't see the data (errors) I have planted.

I think there may be problems the way I've coded up the procedures.  Can you please review to see if this can be optimised to make the code more reliable.

Start Free Trial
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:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
Sub CycleSheets(Wb As String)
 
Dim sht As String
 
Workbooks(Wb).Activate
 
For a = 6 To 22
Worksheets("Index Quarries").Select
sht = Range(Cells(a, 3), Cells(a, 3)).Text
 
Call checkerror(Wb, sht)
 
Next a
 
End Sub
 
Sub checkerror(wkbook As String, shtname As String)
 
Dim d As Integer
Dim c As Integer
 
 
Workbooks(wkbook).Activate
Worksheets(shtname).Select
 
 
'Error 1 : Check for volumes with no price
 
For a = 12 To 100 ' Group purchase lines
    If Cells(a, 2) = "" Then
        lastrow = a - 1
        a = 101
    End If
Next a
 
 
For b = 21 To 32 'Jan-Dec volumes
    For d = 13 To lastrow
        If Cells(d, b) > 0 Then
            If Cells(d, b + 26) <= 0 Then
                Call ReportError(ActiveWorkbook.Name, shtname, d, b + 26, "Critical", "For this period, a volume is input with no price.  Please enter a price.")
            End If
        End If
    Next d
Next b
 
End Sub
 
Sub ReportError(fname As String, sname As String, rw As Integer, cl As Integer, stat As String, mess As String)
 
Workbooks("Validation.xls").Activate
 
 
last_row = Worksheets("Log").[A2]
 
 
Worksheets("Log").Select
    
    Range(Cells(last_row, 1), Cells(last_row, 1)) = fname
    Range(Cells(last_row, 2), Cells(last_row, 2)) = sname
    Range(Cells(last_row, 3), Cells(last_row, 3)) = rw
    Range(Cells(last_row, 4), Cells(last_row, 4)) = cl
    Range(Cells(last_row, 6), Cells(last_row, 6)) = stat
    Range(Cells(last_row, 7), Cells(last_row, 7)) = mess
   
 
Workbooks(fname).Activate
 
End Sub
[+][-]05.30.2008 at 08:36AM PDT, ID: 21678755

View this solution now by starting your 14-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
Tags: Microsoft, Excel, 2003
Sign Up Now!
Solution Provided By: rorya
Participating Experts: 1
Solution Grade: B
 
 
 
Loading Advertisement...
20081112-EE-VQP-43 / EE_QW_2_20070628