PDA

View Full Version : Debugging Question



av8tordude
03-01-2011, 08:24 AM
What does this part of the code do?


If LenB(Table) = 0 Or Table < 11 Then


It part of this code is below



If LenB(Table) = 0 Or Table < 11 Then
With Application.WorksheetFunction
Table = .CountA(Range("Expense").Columns(1)) + 1
End With
End If

IBihy
03-01-2011, 08:49 AM
Hello,

Jeez, does this snippet work at all? From what you supply, it looks goofy. How is "Table" set? Apparently, it tries to apply a worksheet function, i.e. a formula to cells in a column.

av8tordude
03-01-2011, 09:00 AM
Private Table As Long

Is the table limited to only 11 rows? The table I have has 500

Tommy
03-01-2011, 09:10 AM
It looks like it is checking to see if the value of table is =0 or less than 11 if it is set it to the number of rows in the Named range "Expense" + 1. In other words the next record.

I really don't understand the lenb, that is normally used on strings.

EDIT: ADDED + 1 Tommy

av8tordude
03-01-2011, 09:16 AM
Why each time I enter the 12th entry of a table of 500 available entries, it deletes the 11th entry?

1 01/15/10 Other Organization Dues $46.28 $0.00
2 02/15/10 Other Organization Dues $46.28 $0.00
3 03/15/10 Other Organization Dues $46.28 $0.00
4 04/15/10 Other Organization Dues $46.28 $0.00
5 05/15/10 Other Organization Dues $46.28 $0.00
6 06/15/10 Other Organization Dues $46.28 $0.00
7- 07/15/10 Other Organization Dues $46.28 $0.00
8- 08/15/10 Other Organization Dues $46.28 $0.00
9- 09/15/10 Other Organization Dues $46.28 $0.00
10-10/15/10 Other Organization Dues $46.28 $0.00
12-12/15/10 Other Organization Dues $46.28 $0.00


the rest of the code


Dim I As Integer
Dim tCol As Integer
Dim ExRange As Range
Dim Ans
Dim ToRow As Integer
Dim temp_row As Integer
Ans = MsgBox("Did your employer reimburse you for this expense?", vbQuestion + vbYesNo, "PerDiem Traveler")
If Ans = vbNo Then
On Error Resume Next
If Me.cboDesc.Text = vbNullString Or Me.Amnt.Text = vbNullString Then
MsgBox "All entries must be completed before your expense can be registered.", vbExclamation, "PerDiem Traveler"
Exit Sub
End If
On Error Resume Next
If Me.cboDesc.Text = vbNullString Or Me.Amnt.Text = vbNullString Then
MsgBox "All entries must be completed before your expense can be registered.", vbExclamation, "PerDiem Traveler"
Exit Sub
End If
If cboCat = "All Categories" Then
MsgBox "Select an expense category", vbExclamation, "PerDiem Traveler"
Else
If LenB(Table) = 0 Or Table < 1000 Then
With Application.WorksheetFunction
Table = .CountA(Range("Expense").Columns(1)) + 1
End With
End If
AddNew
With Me.ListBox3
If .ListIndex > -1 Then
ToRow = Sheets("Calculator").Range("BB11").Offset(.ListIndex, 0).Value
On Error GoTo 0
If LenB(.Value) > 0 And Ent5.Caption = "Update" Then 'updating an item....
temp_row = .ListIndex
Range("Expense").Cells(ToRow, 2) = CDate(Me.Date5)
Range("Expense").Cells(ToRow, 3) = cboCat.Value
Range("Expense").Cells(ToRow, 4) = cboDesc.Value
Range("Expense").Cells(ToRow, 5) = CCur(Replace(Me.Amnt, "$", ""))
Range("Expense").Cells(ToRow, 6) = "$0.00"
Load_Itemized
Exit Sub
End If
Else
Range("Expense").Cells(Table, 1) = Application.Max(Range("AU11:AU500")) + 1
Range("Expense").Cells(Table, 2) = CDate(Date5)
Range("Expense").Cells(Table, 3) = cboCat.Value
Range("Expense").Cells(Table, 4) = cboDesc.Value
Range("Expense").Cells(Table, 5) = CCur(Replace(Amnt, "$", ""))
Range("Expense").Cells(Table, 6) = "$0.00"
End If
End With
Range("AV11:AZ500").Sort key1:=Range("AV11"), order1:=xlAscending, Header:=xlNo
LoadList
NewExpense
End If
For tCol = 42 To 46
Set ExRange = ActiveSheet.Range(Cells(10, tCol), Cells(30, tCol))
ExRange.Sort key1:=ExRange.Cells(1, 1), order1:=xlAscending, Header:=xlYes
Next tCol
Else
frmComp.Show
End If

Tommy
03-01-2011, 09:33 AM
Can you post the workbook?

Tommy
03-01-2011, 09:36 AM
I don't see where it is deleting a row in the code posted so it has to be happening somewhere else.