jharvey_22
New Member
- Joined
- Jun 10, 2011
- Messages
- 8
This is my code:
Option Explicit
Dim i As Variant
Dim j As Variant
Dim x As Variant
Dim array1(202, 58) As Variant
Sub Report1()
'First, gather all of the information from the comparison tab
For i = 0 To 202
For j = 0 To 58
array1(i, j) = Worksheets("Comparison").Range("C19").Offset(i, j)
Next j
Next i
'Next, look for errors in the information we just gathered. If there is an error, we will record that
'in the report. Because we know i & j, we know where the error is located in the comparison tab
'using this information, we can easily locate the other information we want for the report
x = 0
For i = 0 To 202
For j = 0 To 58
If IsError(array1(i, j)) Then
x = x + 1
Range("percentchangestart1").Offset(x - 1, 0) = "DIV/0 err" 'this is just a placholder to identify that we have an error
Range("hfmnumber1start").Offset(x - 1, 0) = Worksheets("Comparison").Range("A19").Offset(i, 0) 'since we know the row where the error is, we can look up the HFM # in that row
Range("hfmaccount1start").Offset(x - 1, 0) = Worksheets("comparison").Range("B19").Offset(i, 0) 'since we know the row where the error is, we can look up the HFM account in that row
Range("location1start").Offset(x - 1, 0) = Worksheets("comparison").Range("c15").Offset(0, j) 'since we know the column where the error is, we can look up the entity in that row
End If
Next j
Next i
End Sub
How can I make this faster? It is sooo slow some days. Any help will be much appreciated. Thanks!
Option Explicit
Dim i As Variant
Dim j As Variant
Dim x As Variant
Dim array1(202, 58) As Variant
Sub Report1()
'First, gather all of the information from the comparison tab
For i = 0 To 202
For j = 0 To 58
array1(i, j) = Worksheets("Comparison").Range("C19").Offset(i, j)
Next j
Next i
'Next, look for errors in the information we just gathered. If there is an error, we will record that
'in the report. Because we know i & j, we know where the error is located in the comparison tab
'using this information, we can easily locate the other information we want for the report
x = 0
For i = 0 To 202
For j = 0 To 58
If IsError(array1(i, j)) Then
x = x + 1
Range("percentchangestart1").Offset(x - 1, 0) = "DIV/0 err" 'this is just a placholder to identify that we have an error
Range("hfmnumber1start").Offset(x - 1, 0) = Worksheets("Comparison").Range("A19").Offset(i, 0) 'since we know the row where the error is, we can look up the HFM # in that row
Range("hfmaccount1start").Offset(x - 1, 0) = Worksheets("comparison").Range("B19").Offset(i, 0) 'since we know the row where the error is, we can look up the HFM account in that row
Range("location1start").Offset(x - 1, 0) = Worksheets("comparison").Range("c15").Offset(0, j) 'since we know the column where the error is, we can look up the entity in that row
End If
Next j
Next i
End Sub
How can I make this faster? It is sooo slow some days. Any help will be much appreciated. Thanks!