Hi all,
I'm working on some VBA to automate the creation of a report.
Everything is working perfectly on my pc (win xp, excel 2003) but on my colleagues pc (same os & excel versions) it falls down.
Everything seems to work up until somewhere this section of the code, where it throws up an error 400.
Column I is supposed to check array to see if the value is less than 0, if it is, it puts a 0, else it puts a 1. It then sorts & inserts a Match function to find the first row containing a zero in column I; and after that it will use that match() result as a basis to select only the appropriate range to put into another array.
Problem seems to be that the code below doesn't provide any 1's on my colleagues computer.
This is the code immediately preceeding.
Can anyone see anything obviously wrong here that would cause a problem??
I'm working on some VBA to automate the creation of a report.
Everything is working perfectly on my pc (win xp, excel 2003) but on my colleagues pc (same os & excel versions) it falls down.
Everything seems to work up until somewhere this section of the code, where it throws up an error 400.
Column I is supposed to check array to see if the value is less than 0, if it is, it puts a 0, else it puts a 1. It then sorts & inserts a Match function to find the first row containing a zero in column I; and after that it will use that match() result as a basis to select only the appropriate range to put into another array.
Problem seems to be that the code below doesn't provide any 1's on my colleagues computer.
Code:
If strTempAry(n + 1, 21) < 1 Then
Worksheets("Details").Range("I" & n + 1).Value = 0
Else
Worksheets("Details").Range("I" & n + 1).Value = 1
End If
This is the code immediately preceeding.
Code:
Worksheets("Details").Activate
' Loop through the array
n = 0
While n < UBound(strTempAry)
If Left(strTempAry(n + 1, 1), 1) = "Z" Or Left(strTempAry(n + 1, 7), 3) <> 210 Then
' Skip it
n = n + 1
Else
If strTempAry(n + 1, 9) = Null Then
' Skip it
n = n + 1
Else
Worksheets("Details").Range("A" & n + 1).Select
Worksheets("Details").Range("A" & n + 1).Value = strTempAry(n + 1, 21)
Worksheets("Details").Range("B" & n + 1).Value = strTempAry(n + 1, 1)
Worksheets("Details").Range("C" & n + 1).Value = strTempAry(n + 1, 2)
Worksheets("Details").Range("D" & n + 1).Value = strTempAry(n + 1, 7)
Worksheets("Details").Range("E" & n + 1).Value = strTempAry(n + 1, 8)
Worksheets("Details").Range("F" & n + 1).Value = strTempAry(n + 1, 9)
Worksheets("Details").Range("G" & n + 1).Value = strTempAry(n + 1, 11)
Worksheets("Details").Range("H" & n + 1).Value = strTempAry(n + 1, 13)
If strTempAry(n + 1, 21) < 1 Then
Worksheets("Details").Range("I" & n + 1).Value = 0
Else
Worksheets("Details").Range("I" & n + 1).Value = 1
End If
n = n + 1
End If
End If
Wend
xVal = Sheets("Details").Cells(Rows.Count, 1).End(xlUp).Row
Worksheets("Details").Range("A1:I" & xVal).Select
Selection.Sort Key1:=Worksheets("Details").Range("A1"), Order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Worksheets("Details").Range("K1").Value = "=match(0,I:I,0)-1"
Can anyone see anything obviously wrong here that would cause a problem??